Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Cameron <quozl@laptop.org>2011-01-21 18:10:34 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2011-02-05 15:25:03 (GMT)
commitcbba08f28bc461f06da56d27bca058900c090139 (patch)
tree03e5a00abeb3be09845833d5e0da9b5191489511
parent58af70519711f398c407109cff78066ae54f33ce (diff)
implement discarding network history (SL#1673)
User interface changes: - enable the discard network history button in the network control panel, which also now forces a disconnect, and will be insensitive if there are no networks to be discarded, (rather than the button doing nothing), [split out from larger "fix network disconnect and discard history" patch; replaced count_*() with have_*(); added FIXME] Signed-off-by: Sascha Silbe <silbe@activitycentral.com> Reviewed-by: Sascha Silbe <silbe@activitycentral.com>
-rw-r--r--extensions/cpsection/network/model.py9
-rw-r--r--extensions/cpsection/network/view.py8
-rw-r--r--src/jarabe/model/network.py56
3 files changed, 62 insertions, 11 deletions
diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py
index 8426b7f..916ce8c 100644
--- a/extensions/cpsection/network/model.py
+++ b/extensions/cpsection/network/model.py
@@ -19,6 +19,9 @@ import dbus
from gettext import gettext as _
import gconf
+from jarabe.model import network
+
+
_NM_SERVICE = 'org.freedesktop.NetworkManager'
_NM_PATH = '/org/freedesktop/NetworkManager'
_NM_IFACE = 'org.freedesktop.NetworkManager'
@@ -109,7 +112,11 @@ def clear_registration():
def clear_networks():
"""Clear saved passwords and network configurations.
"""
- pass
+ network.clear_wifi_connections()
+
+
+def have_networks():
+ return network.have_wifi_connections()
def get_publish_information():
diff --git a/extensions/cpsection/network/view.py b/extensions/cpsection/network/view.py
index 9ecc8fd..381dcb6 100644
--- a/extensions/cpsection/network/view.py
+++ b/extensions/cpsection/network/view.py
@@ -106,6 +106,8 @@ class Network(SectionView):
self._clear_history_button = gtk.Button()
self._clear_history_button.set_label(_('Discard network history'))
box_clear_history.pack_start(self._clear_history_button, expand=False)
+ if not self._model.have_networks():
+ self._clear_history_button.set_sensitive(False)
self._clear_history_button.show()
box_wireless.pack_start(box_clear_history, expand=False)
box_clear_history.show()
@@ -220,6 +222,8 @@ class Network(SectionView):
self._radio_valid = False
else:
self._radio_valid = True
+ if self._model.have_networks():
+ self._clear_history_button.set_sensitive(True)
self._validate()
return False
@@ -250,4 +254,8 @@ class Network(SectionView):
return False
def __network_configuration_reset_cb(self, widget):
+ # FIXME: takes effect immediately, not after CP is closed with
+ # confirmation button
self._model.clear_networks()
+ if not self._model.have_networks():
+ self._clear_history_button.set_sensitive(False)
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index 1eb34ab..037f90f 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -521,6 +521,14 @@ class NMSettings(dbus.service.Object):
self.secrets_request.send(self, connection=sender,
response=kwargs['response'])
+ def clear_wifi_connections(self):
+ for uuid in self.connections.keys():
+ conn = self.connections[uuid]
+ if conn._settings.connection.type == \
+ NM_CONNECTION_TYPE_802_11_WIRELESS:
+ conn.Removed()
+ self.connections.pop(uuid)
+
class SecretsResponse(object):
"""Intermediate object to report the secrets from the dialog
@@ -551,6 +559,16 @@ class NMSettingsConnection(dbus.service.Object):
self._settings = settings
self._secrets = secrets
+ @dbus.service.signal(dbus_interface=NM_CONNECTION_IFACE,
+ signature='')
+ def Removed(self):
+ pass
+
+ @dbus.service.signal(dbus_interface=NM_CONNECTION_IFACE,
+ signature='a{sa{sv}}')
+ def Updated(self, settings):
+ pass
+
def set_connected(self):
if self._settings.connection.type == NM_CONNECTION_TYPE_GSM:
self._settings.connection.timestamp = int(time.time())
@@ -559,6 +577,7 @@ class NMSettingsConnection(dbus.service.Object):
self._settings.connection.timestamp = int(time.time())
if (self._settings.connection.type ==
NM_CONNECTION_TYPE_802_11_WIRELESS):
+ self.Updated(self._settings.get_dict())
self.save()
try:
@@ -582,8 +601,7 @@ class NMSettingsConnection(dbus.service.Object):
return self._settings
def save(self):
- profile_path = env.get_profile_path()
- config_path = os.path.join(profile_path, 'nm', 'connections.cfg')
+ config_path = _get_wifi_connections_path()
config = ConfigParser.ConfigParser()
try:
@@ -812,19 +830,25 @@ def add_connection(uuid, settings, secrets=None):
return conn
-def load_wifi_connections():
+def _get_wifi_connections_path():
profile_path = env.get_profile_path()
- config_path = os.path.join(profile_path, 'nm', 'connections.cfg')
+ return os.path.join(profile_path, 'nm', 'connections.cfg')
+
+
+def _create_wifi_connections(config_path):
+ if not os.path.exists(os.path.dirname(config_path)):
+ os.makedirs(os.path.dirname(config_path), 0755)
+ f = open(config_path, 'w')
+ f.close()
- config = ConfigParser.ConfigParser()
+
+def load_wifi_connections():
+ config_path = _get_wifi_connections_path()
if not os.path.exists(config_path):
- if not os.path.exists(os.path.dirname(config_path)):
- os.makedirs(os.path.dirname(config_path), 0755)
- f = open(config_path, 'w')
- config.write(f)
- f.close()
+ _create_wifi_connections(config_path)
+ config = ConfigParser.ConfigParser()
try:
if not config.read(config_path):
logging.error('Error reading the nm config file')
@@ -932,3 +956,15 @@ def find_gsm_connection():
logging.debug('There is no gsm connection in the NMSettings.')
return None
+
+
+def have_wifi_connections():
+ return bool(get_settings().connections)
+
+
+def clear_wifi_connections():
+ if _nm_settings is not None:
+ _nm_settings.clear_wifi_connections()
+
+ config_path = _get_wifi_connections_path()
+ _create_wifi_connections(config_path)