Ticket #1673: 0001-restore-discard-network-history-function.patch

File 0001-restore-discard-network-history-function.patch, 2.2 KB (added by quozl, 11 years ago)

Patch to Sugar 0.84 restores the discard network history button to normal operation. Review requested.

  • extensions/cpsection/network/model.py

    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  
    1717
    1818import dbus
    1919from gettext import gettext as _
     20from jarabe.model import network
    2021import gconf
    2122
    2223_NM_SERVICE = 'org.freedesktop.NetworkManager'
    def clear_registration(): 
    116117def clear_networks():
    117118    """Clear saved passwords and network configurations.
    118119    """
    119     pass
     120    network.clear_networks()
    120121
    121122def get_publish_information():
    122123    client = gconf.client_get_default()
  • src/jarabe/model/network.py

    diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
    index c1f7969..0023ff1 100644
    a b def load_connections(): 
    535535            logging.error('Error reading section: %s' % e)
    536536        else:
    537537            add_connection(ssid, settings, secrets)
     538
     539def 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()