[PATCH 0/6] Auto-mount network drives per wifi connection

Hi everybody,

I just finished a patch to NetworkManager & nm-applet that adds auto-mounting of network drives on a per-wifi-connection basis.

I already mentioned the raison-d'être on IRC some days ago: I wanted our home NAS shares mounted on my wife's laptop whenever she connects it to our home wifi. And I wanted it to be easy enough so that she (not having a CS degree) would be able to set it up on her own - like the wifi connection or connecting the NAS manually. When searching in Google, many people seem to have the same problem.

The NetworkManager and its applet seem like the natural place for that feature: They distinguish wifi connections and know the connect/disconnect events. Considering network drives a network resource would also allow adding other resources on a per-connection basis later, such as proxy settings (which is on the NM TODO-list) or default printers. So the Connection Editor would be the perfect place for configuring these resources.

First thing I tried was hooking on to the if-up/down-scripts: This failed, as those scripts are run by NetworkManager running as root, while gvfs-mount requires access to the user's keyring (which sudo/gksu couldn't provide). For this reason, the patch mostly touches nm-applet (running as logged-in user).

The patchset consists of the following parts:
- in NetworkManager/libnm-util: a new settings category, nm-settings-resources, holding the uri strings of the network drives to be mounted - in nm-applet/Connection Editor: a new page (ce-page-resources) for configuring auto-mounts for wifi connections - in nm-applet/applet-device-wifi: mount configured network drives on connect, unmount on disconnect - in nm-applet/applet: volume monitor asking the user via libnotify if (s)he wishes to add/remove auto-mounts whenever s(he) manually (un)mounts network drives via gvfs/nautilus

Along the way, I also updated the settings-template to the best practices I found in other settings files (most notably error quarks). I don't know if this is correct, but I included the changes in the patch.

The next steps I'd approach would be adding support for VPN connections and proxy settings. Before I begin, I'd appreciate feedback for the patch:
- Does it make sense this way?
- Doing the actual mounts/unmounts in applet-device-wifi is clearly the wrong place. I'd think of a general resources class in nm-applet that would be signaled from each supported applet-device-* class. - Changing the (network drives configuration) requires getting & re-storing the specific secret settings, which makes the code more complex. This probably gets worse when supporting more connection types. Maybe there's another way?
- There might be a better place than the applet class for the volume monitor
- The unmount counting would formally be more correct with white/blacklisting the network drives that re auto-unmounted (rather than basically just disabling the monitor for 10 seconds)

I wasn't sure on how to send this patch, so I try to imitate the style I found in the archives:

 libnm-util/Makefile.am            |    2 +
 libnm-util/libnm-util.ver         |   13 ++
 libnm-util/nm-connection.c        |   25 +++-
 libnm-util/nm-connection.h        |    2 +
libnm-util/nm-setting-resources.c | 381 +++++++++++++++++++++++++++++++++++++
 libnm-util/nm-setting-resources.h |   90 +++++++++
 libnm-util/nm-setting-template.c  |   26 +++-
 libnm-util/nm-setting-template.h  |    3 +
 libnm-util/nm-utils.c             |   49 +++++
 libnm-util/nm-utils.h             |    2 +
 libnm-util/tests/test-general.c   |   55 ++++++
 11 files changed, 646 insertions(+), 2 deletions(-)

 src/applet-device-wifi.c                     |  189 ++++++++-
 src/applet.c                                 |  441 +++++++++++++++++++
 src/applet.h                                 |    6 +
 src/connection-editor/Makefile.am            |    3 +
 src/connection-editor/ce-page-resources.ui   |  155 +++++++
 src/connection-editor/nm-connection-editor.c |    3 +
src/connection-editor/page-resources.c | 588 ++++++++++++++++++++++++++
 src/connection-editor/page-resources.h       |   58 +++
 8 files changed, 1434 insertions(+), 9 deletions(-)

- splitted into 6 mails, logically grouped.

Excited for the reactions - this is my first contribution to an OS project ever!


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