VeryPluggableBackends (VPB) is a branch of Wicd that is currently under development which supports multiple network interfaces and multiple simultaneous connections.
Using VPB
Keep in mind that VPB is under development and may not work as expected.
Throughout this page, I will use wlan0 as the wireless interface, and eth0 as the wired interface. Substitute your interface names where appropriate.
Starting the daemon
You need to start the Wicd daemon before you can do anything else. Since this is a development version, setup.py will not work. Just cd into the directory containing wicd-daemon.py and run (as root)
python wicd-daemon.py -foe
The daemon should now be running (it will stay in the foreground since you are using the -f switch) and you can continue to the next step.
Adding an interface
At the moment, VPB supports wired and wireless network connections, but more can easily be added easier. Support for PPPoE, VPN, 3G or even via Bluetooth/cell phone are all possible, just not implemented. If you are interested in implementing one of these, feel free to ask on our IRC channel.
To add an interface, you need to use cli.py. (the GUI is not far enough along to support this yet)
python cli.py --create-interface -i wlan0 -t wireless python cli.py --create-interface -i eth0 -t wired
The first command will create a wireless interface based on your wlan0 device, and the second will create a wired interface based on your eth0 device. You don't have to run both of them, or either of them, for Wicd to work properly. However, Wicd won't be of any use to you if you don't make at least one interface.
Opening the Wicd console
To access the Wicd daemon from the command line (for now) just run
python -i wicd-console.py
This will load a Python interpreter with Wicd interfaces already loaded. Now you can use the interface name (wlan0, eth0, etc) to access the methods of the interface. You'll need this for the next few steps.
Viewing available wireless networks
In order to connect to a wireless network, you need to know its BSSID. To get this information from Wicd, run
wlan0.do_scan() wlan0.get_networks()
This will trigger a scan for wireless networks, and then will print the ESSID and BSSIDs of the available wireless networks. You will need to wait for the scan to finish before running the second command, otherwise you will get WicdError: Interface is not idle. Any time you see a similar error, wait a few seconds and run the command again.
Setting up a network
Wireless networks
Unsecured networks need no setup.
Encrypted networks are trickier. You'll need to set up the encryption properties before you can connect. VPB only supports unencrypted and WPA passphrase secured networks at the moment, but more encryption schemes will be added in the future.
wlan0.set_profile_property("00:11:22:33:44:55:66", "encryption_type", "WpaPassphrase")
wlan0.set_profile_property("00:11:22:33:44:55:66", "passphrase", "yourwpapassphrasegoeshere")The first argument is the BSSID of the AP for which you want to set these properties (obviously, you'll need to use the BSSID of your AP instead of the one in the example). The first command tells Wicd you want to use the WpaPassphrase encryption scheme, and the second supplies Wicd with your PSK.
Assuming you want to use DHCP, you're done.
Wired networks
Wired networks are very similar to wireless networks. A couple of small differences:
First, you'll need to make a wired network profile. This way, you can easily switch the settings for different locations. (In fact, Wicd can even do that for you. More on that later.)
eth0.do_create_profile("NameOfProfileCanBeWhateverYouWant")Assuming you want to use DHCP, you're done.
Using static IP and DNS servers
I hope you're ready to type. Note that the interface can be either wireless or wired, but I've used eth0 here.
eth0.set_profile_property("00:11:22:33:44:55:66", 'static_ip', "10.0.1.200")
eth0.set_profile_property("00:11:22:33:44:55:66", 'static_netmask', "255.255.255.0")
eth0.set_profile_property("00:11:22:33:44:55:66", 'static_gateway', "10.0.1.1")
eth0.set_profile_property("00:11:22:33:44:55:66", 'static_dns_1', "208.67.220.220")
eth0.set_profile_property("00:11:22:33:44:55:66", 'static_dns_2', "208.67.222.222")
eth0.set_profile_property("00:11:22:33:44:55:66", 'static_dns_3', "None")
eth0.set_profile_property("00:11:22:33:44:55:66", 'use_static_ip', "True")This will set up the currently selected network profile on eth0 to use an IP of 10.0.1.200, a netmask of 255.255.255.0, a gateway of 10.0.1.1, and the OpenDNS DNS servers.
Connecting to a network
This is the easy part.
wlan0.do_connect("00:11:22:33:44:55:66")All done.
VPB Coding
Overview
VPB is written in Python. It has two main ways of extending it: writing a backend, or a plugin.
Backends
This is the most important part of VPB. By writing a new backend, Wicd can configure any device and do just about anything. Right now, Wicd has just one major backend, called be-ip4network, which contains the wireless and wired backends. They are grouped into one major backend because they share much of the same code, so it didn't make sense to have two backends that duplicated code.
Plugins
Plugins are an easy way to add functionality that affects one or more backends. For instance, Wicd has a scan.py plugin that will automatically trigger a wireless network scan when Wicd is started. Note that these plugins should not implement functionality that the backends depend on. Plugins can be added or removed at any time without modifying any code. In a sense, plugins are like DBus clients; they can be added or removed at any time, and they do not perform any critical backend functions.
Layout
First, take a look at the layout diagram.
ProxyInterface
ProxyInterface allows you to make an object representing the interface that will make it easy to change the way Wicd communicates with the daemon without rewriting the whole client should the need arise.
1 from proxyinterface import ProxyInterface
2 wlan0 = ProxyInterface('wlan0')
3 wlan0.set_profile_property("00:11:22:33:44:55:66", 'encryption_type', 'WpaPassphrase')
Backends
Backends are where most of the work is done.
Backend layout
When you write a backend for Wicd, it doesn't matter what you do or how you do it so long as you provide a file called interface.py (and provide a reference to it in init.py [see the be-ip4network backend that comes with Wicd]). DBus clients can only access methods in interface.py, and only methods that have the @public decorator. This to prevent malicious users from manipulating the daemon. interface.py should extend baseinterface.py, as it provides methods Wicd will expect to exist. Some methods provided by baseinterface.py must be overridden in order for Wicd to function properly.
wglobals
wglobals.py holds module-global references that refer to oft-used objects, such as global_config. This allows easy-to-use objects that don't have to be instantiated every time you wish to use one, and, in the case of configuration files, means that there are not multiple objects operating on one file simultaneously.
Logging
VPB uses the logging module that ships with Python. If you want to provide logging in a plugin or backend, just import logging, and use logging.debug, logging.info, etc, to provide output. Wicd will automatically log it to the correct file and (if the user wishes) send it to the standard out.
VPB GUI
VPB sports an entirely new GUI, in part because Wicd 1.5.x's GUI would get very crowded very quickly if it had to display multiple interfaces at once.
This is (a preliminary version of) the GUI you are presented with when you run gui.py. The one in the SVN repository has all the connect/disconnect buttons working correctly, unlike this screenshot. It contains one entry for each interface registered with Wicd. Clicking "Settings" will (in the future) open a dialog containing information about available wireless networks, wired profiles, and other settings. At the moment, it opens a Network Address dialog that doesn't work.
GUI Backends
You may be wondering how the GUI copes with a completely extensible backend. It doesn't. Backend writers have to write a GTK class (subclassing an HBox) that will become the entry Wicd will use in the GUI. This file must be named "gtkui", placed in a directory called "ui" in the directory that contains interface.py, and the GUI will automatically load it if it exists. Any import errors will be ignored by the UI manager. You can look at the ones that ship with the wired and wireless backends to see examples.
