[Sugar-devel] [PATCH] Use NetworkManager to generate connection UUIDs
Daniel Drake
dsd at laptop.org
Mon Oct 8 17:48:30 EDT 2012
Recent versions of NetworkManager have gotten stricter when checking
UUIDs. A UUID must be 32 hex characters plus 4 dashes.
Sugar's unique_id() doesn't satisify this. Switch to using NM
to generate UUIDs.
---
src/jarabe/desktop/networkviews.py | 4 ++--
src/jarabe/model/adhoc.py | 4 ++--
src/jarabe/model/network.py | 4 ++--
src/jarabe/model/olpcmesh.py | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/jarabe/desktop/networkviews.py b/src/jarabe/desktop/networkviews.py
index c949b7e..02ab2b7 100644
--- a/src/jarabe/desktop/networkviews.py
+++ b/src/jarabe/desktop/networkviews.py
@@ -22,6 +22,7 @@ import hashlib
import dbus
import glib
+from gi.repository import NetworkManager
from sugar3.graphics.icon import Icon
from sugar3.graphics.xocolor import XoColor
@@ -30,7 +31,6 @@ from sugar3.graphics import style
from sugar3.graphics.icon import get_icon_state
from sugar3.graphics import palette
from sugar3.graphics.menuitem import MenuItem
-from sugar3.util import unique_id
from sugar3 import profile
from jarabe.view.pulsingicon import EventPulsingIcon
@@ -346,7 +346,7 @@ class WirelessNetworkView(EventPulsingIcon):
logging.debug('Creating new connection for SSID %r', self._ssid)
settings = Settings()
settings.connection.id = self._display_name
- settings.connection.uuid = unique_id()
+ settings.connection.uuid = NetworkManager.utils_uuid_generate()
settings.connection.type = '802-11-wireless'
settings.wireless.ssid = self._ssid
diff --git a/src/jarabe/model/adhoc.py b/src/jarabe/model/adhoc.py
index dfd6caa..7b2c3ea 100644
--- a/src/jarabe/model/adhoc.py
+++ b/src/jarabe/model/adhoc.py
@@ -18,10 +18,10 @@ import logging
import dbus
from gi.repository import GObject
+from gi.repository import NetworkManager
from jarabe.model import network
from jarabe.model.network import Settings
-from sugar3.util import unique_id
from jarabe.model.network import IP4Config
@@ -187,7 +187,7 @@ class AdHocManager(GObject.GObject):
ssid = 'Ad-hoc Network %d' % (channel,)
settings = Settings()
settings.connection.id = self._get_connection_id(channel)
- settings.connection.uuid = unique_id()
+ settings.connection.uuid = NetworkManager.utils_uuid_generate()
settings.connection.type = '802-11-wireless'
settings.connection.autoconnect = False
settings.wireless.ssid = dbus.ByteArray(ssid)
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index 930ba13..043a6a2 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -27,11 +27,11 @@ import dbus.service
from gi.repository import GObject
import ConfigParser
from gi.repository import GConf
+from gi.repository import NetworkManager
import ctypes
from sugar3 import dispatch
from sugar3 import env
-from sugar3.util import unique_id
NM_STATE_UNKNOWN = 0
NM_STATE_ASLEEP = 10
@@ -991,7 +991,7 @@ def create_gsm_connection(username, password, number, apn, pin):
settings.connection.id = GSM_CONNECTION_ID
settings.connection.type = NM_CONNECTION_TYPE_GSM
- settings.connection.uuid = unique_id()
+ settings.connection.uuid = NetworkManager.utils_uuid_generate()
settings.connection.autoconnect = False
settings.ip4_config.method = 'auto'
settings.serial.baud = GSM_BAUD_RATE
diff --git a/src/jarabe/model/olpcmesh.py b/src/jarabe/model/olpcmesh.py
index c2a81f5..dd35c29 100644
--- a/src/jarabe/model/olpcmesh.py
+++ b/src/jarabe/model/olpcmesh.py
@@ -18,11 +18,11 @@ import logging
import dbus
from gi.repository import GObject
+from gi.repository import NetworkManager
from jarabe.model import network
from jarabe.model.network import Settings
from jarabe.model.network import OlpcMesh as OlpcMeshSettings
-from sugar3.util import unique_id
_XS_ANYCAST = '\xc0\x27\xc0\x27\xc0\x00'
@@ -177,7 +177,7 @@ class OlpcMeshManager(object):
settings.ip4_config.method = 'link-local'
settings.connection.id = self._get_connection_id(channel, xs_hosted)
settings.connection.autoconnect = False
- settings.connection.uuid = unique_id()
+ settings.connection.uuid = NetworkManager.utils_uuid_generate()
settings.connection.type = '802-11-olpc-mesh'
network.add_connection(settings,
reply_handler=self._add_connection_reply_cb,
--
1.7.11.4
More information about the Sugar-devel
mailing list