From 5086cee465cc9b9425f3286a22dd5281daee5b6b Mon Sep 17 00:00:00 2001
From: James Cameron <quozl@laptop.org>
Date: Mon, 15 Mar 2010 14:51:03 +1100
Subject: [PATCH] restore discard network history function
- clears the current network configuration (_nm_settings),
- creates an empty connections.cfg file.
http://bugs.sugarlabs.org/ticket/1673
http://dev.laptop.org/ticket/9977
Tested on Sugar 0.84.2 on XO-1.5 build os108, test setup was a single
access point with no encryption, Sugar was configured to join the
network on startup and connections.cfg was non-zero size. After
clicking on "discard network history" button, the connections.cfg file
was zero size, and a Sugar restart did not automatically rejoin the
network.
---
extensions/cpsection/network/model.py | 3 ++-
src/jarabe/model/network.py | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py
index 87db6d9..0e44600 100644
a
|
b
|
|
17 | 17 | |
18 | 18 | import dbus |
19 | 19 | from gettext import gettext as _ |
| 20 | from jarabe.model import network |
20 | 21 | import gconf |
21 | 22 | |
22 | 23 | _NM_SERVICE = 'org.freedesktop.NetworkManager' |
… |
… |
def clear_registration(): |
116 | 117 | def clear_networks(): |
117 | 118 | """Clear saved passwords and network configurations. |
118 | 119 | """ |
119 | | pass |
| 120 | network.clear_networks() |
120 | 121 | |
121 | 122 | def get_publish_information(): |
122 | 123 | client = gconf.client_get_default() |
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index c1f7969..0023ff1 100644
a
|
b
|
def load_connections(): |
535 | 535 | logging.error('Error reading section: %s' % e) |
536 | 536 | else: |
537 | 537 | add_connection(ssid, settings, secrets) |
| 538 | |
| 539 | def clear_networks(): |
| 540 | global _nm_settings |
| 541 | _nm_settings = None |
| 542 | |
| 543 | profile_path = env.get_profile_path() |
| 544 | config_path = os.path.join(profile_path, 'nm', 'connections.cfg') |
| 545 | config = ConfigParser.ConfigParser() |
| 546 | |
| 547 | if not os.path.exists(os.path.dirname(config_path)): |
| 548 | os.makedirs(os.path.dirname(config_path), 0755) |
| 549 | f = open(config_path, 'w') |
| 550 | config.write(f) |
| 551 | f.close() |