Search This Blog

Saturday, July 14, 2012

Improving QtNetworkManager (former libnm-qt)

One of the big changes in master branch last year was the introduction of QtNetworkManager. Well, it still needs work and here I want to talk about what is needed:

Move the create/update/delete connections code to QtNetworkManager

The port of Plasma NM to use QtNetworkManager is not finished, one the things that must be done is move the code that creates/updates/deletes connections from Plasma NM to QtNetworkManager. It means moving most of the code in git:// to git:// and updating Plasma NM to use it. It sounds easy but it is not. The code in networkmanagement/backends/NetworkManager/ depends on some classes that belongs to Plasma NM and will not be moved, so new classes will have to be created to replace them.

Move the DBus parsing code to QtNetworkManager

This code is in git://{cpp,h} and is essencial for any program that want to create connections with NetworkManager.

Create examples about how to use QtNetworkManager

This is a request that I received some time ago. I added some examples in git:// Some things cannot be done in QtNetworkManager yet (creating new connections is troublesome because the DBus parsing code is in Plasma NM right now). I need to finish that part before I can create examples of how to create/edit connections.

Anyone can help with those parts. It is not a simple task (if it were I would have done it long ago), if you think you are up to the challenge contact me :-)

Other things to implement


Anonymous said...

Commenting on an old entry here, but... is this implemented in Qt somewhere? Because I can't find any documentation regarding it. All I find on a search is your blog.

I'd like to write a somewhat dumbed-down frontend to NetworkManager in PyQt for a mobile broadband USB thingy that only shows if the device is connected and a button for "Connect" and "Disconnect" depending on the connection status.

The NM plasmoid and other system tray-confined frontends are too confusing and difficult to read for my user, any guidance appreciated. :)

Lamarque said...

No, libnm-qt is being developed by me with the help of some other guys, it is not an official Qt's module and there is no documentation so far except the source code and the examples in the git repository.

You can create a dumb frontend to NetworkManager using dbus to list and (de)activate the connections. The listing part can be troublesome since you would need to parse the long dbus output for the connection. I guess you just need the connection name and its status for a dumb frontend to you can look just for that and ignore the rest of the configuration.

For instance this list the dbus path of all connections:
dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Settings org.freedesktop.NetworkManager.Settings.ListConnection

this list the settings of a particular connection (connection 0):

dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Settings/0 org.freedesktop.NetworkManager.Settings.Connection.GetSettings

You need to parse the output of the command above to get the connection name, whici is in the field "id" of the "connection" dict. For the status (activated/deactivated) you need to parse the properties of the device the connection is associated with. For instance, if you have a wifi connection it is associated to the wifi device (the NetworkManager's object that represents the wifi card). For instance this lists the properties of the first wifi card in the computer:

dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/0 org.freedesktop.DBus.Properties.GetAll string:org.freedesktop.NetworkManager.Device

The state field contains 100, which means the device is activated. You can know what the values mean in