Blob Blame History Raw
--- sugar-0.92.1/extensions/deviceicon/network.py.orig	2011-05-24 19:54:30.168926832 +0100
+++ sugar-0.92.1/extensions/deviceicon/network.py	2011-05-24 20:01:10.774611988 +0100
@@ -3,6 +3,8 @@
 # Copyright (C) 2009 Tomeu Vizoso, Simon Schampijer
 # Copyright (C) 2009 Paraguay Educa, Martin Abente
 # Copyright (C) 2010 Plan Ceibal, Daniel Castelo
+# Copyright (C) 2011 Peter Robinson
+# Copyright (C) 2011 John Dulaney (jdulaney)
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -54,10 +56,11 @@
 _NM_DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device'
 _NM_WIRED_IFACE = 'org.freedesktop.NetworkManager.Device.Wired'
 _NM_WIRELESS_IFACE = 'org.freedesktop.NetworkManager.Device.Wireless'
-_NM_SERIAL_IFACE = 'org.freedesktop.NetworkManager.Device.Serial'
+_NM_MODEM_IFACE = 'org.freedesktop.NetworkManager.Device.Modem'
 _NM_OLPC_MESH_IFACE = 'org.freedesktop.NetworkManager.Device.OlpcMesh'
 _NM_ACCESSPOINT_IFACE = 'org.freedesktop.NetworkManager.AccessPoint'
 _NM_ACTIVE_CONN_IFACE = 'org.freedesktop.NetworkManager.Connection.Active'
+_NM_GET_SETTINGS_CONN_IFACE = 'org.freedesktop.NetworkManager.Settings.Connection.GetSettings'
 
 _GSM_STATE_NOT_READY = 0
 _GSM_STATE_DISCONNECTED = 1
@@ -521,11 +524,11 @@
         if self._active_ap_op is not None:
             state = self._device_state
         else:
-            state = network.DEVICE_STATE_UNKNOWN
+            state = network.NM_DEVICE_STATE_UNKNOWN
 
         if self._mode != network.NM_802_11_MODE_ADHOC and \
                 network.is_sugar_adhoc_network(self._name) == False:
-            if state == network.DEVICE_STATE_ACTIVATED:
+            if state == network.NM_DEVICE_STATE_ACTIVATED:
                 icon_name = '%s-connected' % 'network-wireless'
             else:
                 icon_name = 'network-wireless'
@@ -535,20 +538,20 @@
                 self._icon.props.icon_name = icon_name
         else:
             channel = network.frequency_to_channel(self._frequency)
-            if state == network.DEVICE_STATE_ACTIVATED:
+            if state == network.NM_DEVICE_STATE_ACTIVATED:
                 self._icon.props.icon_name = 'network-adhoc-%s-connected' \
                         % channel
             else:
                 self._icon.props.icon_name = 'network-adhoc-%s' % channel
             self._icon.props.base_color = profile.get_color()
 
-        if state == network.DEVICE_STATE_PREPARE or \
-           state == network.DEVICE_STATE_CONFIG or \
-           state == network.DEVICE_STATE_NEED_AUTH or \
-           state == network.DEVICE_STATE_IP_CONFIG:
+        if state == network.NM_DEVICE_STATE_PREPARE or \
+           state == network.NM_DEVICE_STATE_CONFIG or \
+           state == network.NM_DEVICE_STATE_NEED_AUTH or \
+           state == network.NM_DEVICE_STATE_IP_CONFIG:
             self._palette.set_connecting()
             self._icon.props.pulsing = True
-        elif state == network.DEVICE_STATE_ACTIVATED:
+        elif state == network.NM_DEVICE_STATE_ACTIVATED:
             address = self._device_props.Get(_NM_DEVICE_IFACE, 'Ip4Address')
             self._palette.set_connected_with_frequency(self._frequency,
                                                        address)
@@ -651,15 +654,15 @@
     def _update(self):
         state = self._device_state
 
-        if state in [network.DEVICE_STATE_PREPARE,
-                     network.DEVICE_STATE_CONFIG,
-                     network.DEVICE_STATE_NEED_AUTH,
-                     network.DEVICE_STATE_IP_CONFIG]:
+        if state in [network.NM_DEVICE_STATE_PREPARE,
+                     network.NM_DEVICE_STATE_CONFIG,
+                     network.NM_DEVICE_STATE_NEED_AUTH,
+                     network.NM_DEVICE_STATE_IP_CONFIG]:
             self._icon.props.base_color = self._inactive_color
             self._icon.props.pulse_color = profile.get_color()
             self._palette.set_connecting()
             self._icon.props.pulsing = True
-        elif state == network.DEVICE_STATE_ACTIVATED:
+        elif state == network.NM_DEVICE_STATE_ACTIVATED:
             address = self._device_props.Get(_NM_DEVICE_IFACE, 'Ip4Address')
             self._palette.set_connected_with_channel(self._channel, address)
             self._icon.props.base_color = profile.get_color()
@@ -687,7 +690,7 @@
                 obj = self._bus.get_object(_NM_IFACE, ap_op)
                 props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
                 device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
-                if device_type == network.DEVICE_TYPE_802_11_OLPC_MESH:
+                if device_type == network.NM_DEVICE_TYPE_OLPC_MESH:
                     netmgr.DeactivateConnection(conn_o)
                     break
             except dbus.exceptions.DBusException:
@@ -738,7 +741,7 @@
         self._bus.add_signal_receiver(self.__ppp_stats_changed_cb,
                                       signal_name='PppStats',
                                       path=self._device.object_path,
-                                      dbus_interface=_NM_SERIAL_IFACE)
+                                      dbus_interface=_NM_MODEM_IFACE)
 
     def create_palette(self):
         palette = GsmPalette()
@@ -816,7 +819,7 @@
     def _update_state(self, state, old_state, reason):
         gsm_state = None
 
-        if state is network.DEVICE_STATE_ACTIVATED:
+        if state is network.NM_DEVICE_STATE_ACTIVATED:
             gsm_state = _GSM_STATE_CONNECTED
             connection = network.find_gsm_connection()
             if connection is not None:
@@ -830,7 +833,7 @@
                 if self._palette is not None:
                     self._palette.connection_info_box.show()
 
-        elif state is network.DEVICE_STATE_DISCONNECTED:
+        elif state is network.NM_DEVICE_STATE_DISCONNECTED:
             gsm_state = _GSM_STATE_DISCONNECTED
             self._connection_timestamp = 0
             if self._connection_time_handler is not None:
@@ -838,18 +841,18 @@
             if self._palette is not None:
                 self._palette.connection_info_box.hide()
 
-        elif state in [network.DEVICE_STATE_UNMANAGED,
-                       network.DEVICE_STATE_UNAVAILABLE,
-                       network.DEVICE_STATE_UNKNOWN]:
+        elif state in [network.NM_DEVICE_STATE_UNMANAGED,
+                       network.NM_DEVICE_STATE_UNAVAILABLE,
+                       network.NM_DEVICE_STATE_UNKNOWN]:
             gsm_state = _GSM_STATE_NOT_READY
 
-        elif state in [network.DEVICE_STATE_PREPARE,
-                       network.DEVICE_STATE_CONFIG,
-                       network.DEVICE_STATE_IP_CONFIG,
-                       network.DEVICE_STATE_NEED_AUTH]:
+        elif state in [network.NM_DEVICE_STATE_PREPARE,
+                       network.NM_DEVICE_STATE_CONFIG,
+                       network.NM_DEVICE_STATE_IP_CONFIG,
+                       network.NM_DEVICE_STATE_NEED_AUTH]:
             gsm_state = _GSM_STATE_CONNECTING
 
-        elif state == network.DEVICE_STATE_FAILED:
+        elif state == network.NM_DEVICE_STATE_FAILED:
             gsm_state = _GSM_STATE_FAILED
 
         if self._palette is not None:
@@ -929,10 +932,10 @@
         self._update_state(new_state)
 
     def _update_state(self, state):
-        if state in (network.DEVICE_STATE_PREPARE, network.DEVICE_STATE_CONFIG,
-                     network.DEVICE_STATE_NEED_AUTH,
-                     network.DEVICE_STATE_IP_CONFIG,
-                     network.DEVICE_STATE_ACTIVATED):
+        if state in (network.NM_DEVICE_STATE_PREPARE, network.NM_DEVICE_STATE_CONFIG,
+                     network.NM_DEVICE_STATE_NEED_AUTH,
+                     network.NM_DEVICE_STATE_IP_CONFIG,
+                     network.NM_DEVICE_STATE_ACTIVATED):
             if self._device_view is not None:
                 self._device_view.update_state(state)
                 return
@@ -979,7 +982,7 @@
         self._update_state(new_state)
 
     def _update_state(self, state):
-        if state == network.DEVICE_STATE_ACTIVATED:
+        if state == network.NM_DEVICE_STATE_ACTIVATED:
             props = dbus.Interface(self._device, dbus.PROPERTIES_IFACE)
             address = props.Get(_NM_DEVICE_IFACE, 'Ip4Address')
             speed = props.Get(_NM_WIRED_IFACE, 'Speed')
@@ -1043,18 +1046,21 @@
         props = dbus.Interface(nm_device, dbus.PROPERTIES_IFACE)
 
         device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
-        if device_type == network.DEVICE_TYPE_802_3_ETHERNET:
+        if device_type == network.NM_DEVICE_TYPE_ETHERNET:
             device = WiredDeviceObserver(nm_device, self._tray)
             self._devices[device_op] = device
-        elif device_type == network.DEVICE_TYPE_802_11_WIRELESS:
+        elif device_type == network.NM_DEVICE_TYPE_WIFI:
             device = WirelessDeviceObserver(nm_device, self._tray)
             self._devices[device_op] = device
-        elif device_type == network.DEVICE_TYPE_802_11_OLPC_MESH:
+        elif device_type == network.NM_DEVICE_TYPE_OLPC_MESH:
             device = MeshDeviceObserver(nm_device, self._tray)
             self._devices[device_op] = device
-        elif device_type == network.DEVICE_TYPE_GSM_MODEM:
+        elif device_type == network.NM_DEVICE_TYPE_GSM:
             device = GsmDeviceObserver(nm_device, self._tray)
             self._devices[device_op] = device
+        elif device_type == network.NM_DEVICE_TYPE_CDMA:
+            device = CdmaDeviceObserver(nm_device, self._tray)
+            self._devices[device_op] = device
 
     def __device_added_cb(self, device_op):
         self._check_device(device_op)
--- sugar-0.92.1/src/jarabe/desktop/meshbox.py.orig	2011-05-24 19:56:32.757355239 +0100
+++ sugar-0.92.1/src/jarabe/desktop/meshbox.py	2011-05-24 19:58:37.926818590 +0100
@@ -2,6 +2,7 @@
 # Copyright (C) 2009 Tomeu Vizoso, Simon Schampijer
 # Copyright (C) 2009-2010 One Laptop per Child
 # Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
+# Copyright (C) 2011 Peter Robinson
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -350,7 +351,7 @@
         props = dbus.Interface(device, dbus.PROPERTIES_IFACE)
 
         device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType')
-        if device_type == network.DEVICE_TYPE_802_11_WIRELESS:
+        if device_type == network.NM_DEVICE_TYPE_WIRELESS:
             self._devices[device_o] = DeviceObserver(device)
             self._devices[device_o].connect('access-point-added',
                                             self.__ap_added_cb)
@@ -358,7 +359,7 @@
                                             self.__ap_removed_cb)
             if self._have_adhoc_networks:
                 self._box.add_adhoc_networks(device)
-        elif device_type == network.DEVICE_TYPE_802_11_OLPC_MESH:
+        elif device_type == network.NM_DEVICE_TYPE_OLPC_MESH:
             self._olpc_mesh_device_o = device_o
             self._box.enable_olpc_mesh(device)
 
--- sugar-0.92.1/src/jarabe/desktop/networkviews.py.orig	2011-05-24 19:56:40.494445551 +0100
+++ sugar-0.92.1/src/jarabe/desktop/networkviews.py	2011-05-24 19:58:37.927818602 +0100
@@ -1,6 +1,7 @@
 # Copyright (C) 2006-2007 Red Hat, Inc.
 # Copyright (C) 2009 Tomeu Vizoso, Simon Schampijer
 # Copyright (C) 2009-2010 One Laptop per Child
+# Copyright (C) 2011 Peter Robinson
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -189,7 +190,7 @@
                 network.is_sugar_adhoc_network(self._name):
             channel = max([1] + [ap.channel for ap in
                                  self._access_points.values()])
-            if self._device_state == network.DEVICE_STATE_ACTIVATED and \
+            if self._device_state == network.NM_DEVICE_STATE_ACTIVATED and \
                     self._active_ap is not None:
                 icon_name = 'network-adhoc-%s-connected' % channel
             else:
@@ -198,7 +199,7 @@
             icon = self._palette.props.icon
             icon.props.icon_name = icon_name
         else:
-            if self._device_state == network.DEVICE_STATE_ACTIVATED and \
+            if self._device_state == network.NM_DEVICE_STATE_ACTIVATED and \
                     self._active_ap is not None:
                 icon_name = '%s-connected' % _AP_ICON_NAME
             else:
@@ -229,18 +230,18 @@
         if self._active_ap is not None:
             state = self._device_state
         else:
-            state = network.DEVICE_STATE_UNKNOWN
+            state = network.NM_DEVICE_STATE_UNKNOWN
 
-        if state == network.DEVICE_STATE_PREPARE or \
-           state == network.DEVICE_STATE_CONFIG or \
-           state == network.DEVICE_STATE_NEED_AUTH or \
-           state == network.DEVICE_STATE_IP_CONFIG:
+        if state == network.NM_DEVICE_STATE_PREPARE or \
+           state == network.NM_DEVICE_STATE_CONFIG or \
+           state == network.NM_DEVICE_STATE_NEED_AUTH or \
+           state == network.NM_DEVICE_STATE_IP_CONFIG:
             if self._disconnect_item:
                 self._disconnect_item.show()
             self._connect_item.hide()
             self._palette.props.secondary_text = _('Connecting...')
             self.props.pulsing = True
-        elif state == network.DEVICE_STATE_ACTIVATED:
+        elif state == network.NM_DEVICE_STATE_ACTIVATED:
             connection = network.find_connection_by_ssid(self._name)
             if connection is not None:
                 if self._mode == network.NM_802_11_MODE_INFRA:
@@ -521,9 +522,9 @@
         if self._channel == channel:
             state = device_state
         else:
-            state = network.DEVICE_STATE_UNKNOWN
+            state = network.NM_DEVICE_STATE_UNKNOWN
 
-        if state == network.DEVICE_STATE_ACTIVATED:
+        if state == network.NM_DEVICE_STATE_ACTIVATED:
             icon_name = '%s-connected' % (self._ICON_NAME + str(self._channel))
         else:
             icon_name = self._ICON_NAME + str(self._channel)
@@ -533,16 +534,16 @@
             icon = self._palette.props.icon
             icon.props.icon_name = icon_name
 
-        if state in [network.DEVICE_STATE_PREPARE,
-                     network.DEVICE_STATE_CONFIG,
-                     network.DEVICE_STATE_NEED_AUTH,
-                     network.DEVICE_STATE_IP_CONFIG]:
+        if state in [network.NM_DEVICE_STATE_PREPARE,
+                     network.NM_DEVICE_STATE_CONFIG,
+                     network.NM_DEVICE_STATE_NEED_AUTH,
+                     network.NM_DEVICE_STATE_IP_CONFIG]:
             if self._disconnect_item:
                 self._disconnect_item.show()
             self._connect_item.hide()
             self._palette.props.secondary_text = _('Connecting...')
             self.props.pulsing = True
-        elif state == network.DEVICE_STATE_ACTIVATED:
+        elif state == network.NM_DEVICE_STATE_ACTIVATED:
             if self._disconnect_item:
                 self._disconnect_item.show()
             self._connect_item.hide()
@@ -659,18 +660,18 @@
         if self._active:
             state = self._device_state
         else:
-            state = network.DEVICE_STATE_UNKNOWN
+            state = network.NM_DEVICE_STATE_UNKNOWN
 
-        if state in [network.DEVICE_STATE_PREPARE,
-                     network.DEVICE_STATE_CONFIG,
-                     network.DEVICE_STATE_NEED_AUTH,
-                     network.DEVICE_STATE_IP_CONFIG]:
+        if state in [network.NM_DEVICE_STATE_PREPARE,
+                     network.NM_DEVICE_STATE_CONFIG,
+                     network.NM_DEVICE_STATE_NEED_AUTH,
+                     network.NM_DEVICE_STATE_IP_CONFIG]:
             if self._disconnect_item:
                 self._disconnect_item.show()
             self._connect_item.hide()
             self._palette.props.secondary_text = _('Connecting...')
             self.props.pulsing = True
-        elif state == network.DEVICE_STATE_ACTIVATED:
+        elif state == network.NM_DEVICE_STATE_ACTIVATED:
             if self._disconnect_item:
                 self._disconnect_item.show()
             self._connect_item.hide()
--- sugar-0.92.1/src/jarabe/model/adhoc.py.orig	2011-05-24 19:57:39.164130994 +0100
+++ sugar-0.92.1/src/jarabe/model/adhoc.py	2011-05-24 19:58:37.928818614 +0100
@@ -1,4 +1,5 @@
 # Copyright (C) 2010 One Laptop per Child
+# Copyright (C) 2011 Peter Robinson
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -70,7 +71,7 @@
         self._device = None
         self._idle_source = 0
         self._listening_called = 0
-        self._device_state = network.DEVICE_STATE_UNKNOWN
+        self._device_state = network.NM_DEVICE_STATE_UNKNOWN
 
         self._current_channel = None
         self._networks = {self._CHANNEL_1: None,
@@ -151,7 +152,7 @@
             self._AUTOCONNECT_TIMEOUT, self.__idle_check_cb)
 
     def __idle_check_cb(self):
-        if self._device_state == network.DEVICE_STATE_DISCONNECTED:
+        if self._device_state == network.NM_DEVICE_STATE_DISCONNECTED:
             logging.debug('Connect to Ad-hoc network due to inactivity.')
             self._autoconnect_adhoc()
         else:
--- sugar-0.92.1/src/jarabe/model/olpcmesh.py.orig	2011-05-24 19:57:50.072258553 +0100
+++ sugar-0.92.1/src/jarabe/model/olpcmesh.py	2011-05-24 19:58:37.929818625 +0100
@@ -1,4 +1,5 @@
 # Copyright (C) 2009, 2010 One Laptop per Child
+# Copyright (C) 2011 Peter Robinson
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,17 +34,19 @@
 
 _XS_ANYCAST = '\xc0\x27\xc0\x27\xc0\x00'
 
-DEVICE_STATE_UNKNOWN = 0
-DEVICE_STATE_UNMANAGED = 1
-DEVICE_STATE_UNAVAILABLE = 2
-DEVICE_STATE_DISCONNECTED = 3
-DEVICE_STATE_PREPARE = 4
-DEVICE_STATE_CONFIG = 5
-DEVICE_STATE_NEED_AUTH = 6
-DEVICE_STATE_IP_CONFIG = 7
-DEVICE_STATE_ACTIVATED = 8
-DEVICE_STATE_FAILED = 9
-
+NM_DEVICE_STATE_UNKNOWN = 0
+NM_DEVICE_STATE_UNMANAGED = 10
+NM_DEVICE_STATE_UNAVAILABLE = 20
+NM_DEVICE_STATE_DISCONNECTED = 30
+NM_DEVICE_STATE_PREPARE = 40
+NM_DEVICE_STATE_CONFIG = 50
+NM_DEVICE_STATE_NEED_AUTH = 60
+NM_DEVICE_STATE_IP_CONFIG = 70
+NM_DEVICE_STATE_IP_CHECK = 80
+NM_DEVICE_STATE_SECONDARIES = 90
+NM_DEVICE_STATE_ACTIVATED = 100
+NM_DEVICE_STATE_DEACTIVATING = 110
+NM_DEVICE_STATE_FAILED = 120
 
 class OlpcMeshManager(object):
     def __init__(self, mesh_device):
@@ -79,8 +82,8 @@
                                       dbus_interface=_NM_DEVICE_IFACE)
 
         self._idle_source = 0
-        self._mesh_device_state = DEVICE_STATE_UNKNOWN
-        self._eth_device_state = DEVICE_STATE_UNKNOWN
+        self._mesh_device_state = NM_DEVICE_STATE_UNKNOWN
+        self._eth_device_state = NM_DEVICE_STATE_UNKNOWN
 
         if self._have_configured_connections():
             self._start_automesh_timer()
@@ -123,8 +126,8 @@
         self._eth_device_state = new_state
         self._maybe_schedule_idle_check()
 
-        if new_state >= DEVICE_STATE_PREPARE \
-                and new_state <= DEVICE_STATE_ACTIVATED \
+        if new_state >= NM_DEVICE_STATE_PREPARE \
+                and new_state <= NM_DEVICE_STATE_ACTIVATED \
                 and len(self._connection_queue) > 0:
             self._connection_queue = []
 
@@ -132,20 +135,20 @@
         self._mesh_device_state = new_state
         self._maybe_schedule_idle_check()
 
-        if new_state == DEVICE_STATE_FAILED:
+        if new_state == NM_DEVICE_STATE_FAILED:
             self._try_next_connection_from_queue()
-        elif new_state == DEVICE_STATE_ACTIVATED \
+        elif new_state == NM_DEVICE_STATE_ACTIVATED \
                 and len(self._connection_queue) > 0:
             self._empty_connection_queue()
 
     def _maybe_schedule_idle_check(self):
-        if self._mesh_device_state == DEVICE_STATE_DISCONNECTED \
-                and self._eth_device_state == DEVICE_STATE_DISCONNECTED:
+        if self._mesh_device_state == NM_DEVICE_STATE_DISCONNECTED \
+                and self._eth_device_state == NM_DEVICE_STATE_DISCONNECTED:
             self._start_automesh_timer()
 
     def _idle_check(self):
-        if self._mesh_device_state == DEVICE_STATE_DISCONNECTED \
-                and self._eth_device_state == DEVICE_STATE_DISCONNECTED:
+        if self._mesh_device_state == NM_DEVICE_STATE_DISCONNECTED \
+                and self._eth_device_state == NM_DEVICE_STATE_DISCONNECTED:
             logging.debug('starting automesh due to inactivity')
             self._start_automesh()
         return False
--- sugar-0.92.1/src/jarabe/model/network.py.orig	2011-05-24 19:57:58.961362525 +0100
+++ sugar-0.92.1/src/jarabe/model/network.py	2011-05-24 20:03:21.281148686 +0100
@@ -3,6 +3,7 @@
 # Copyright (C) 2009-2010 One Laptop per Child
 # Copyright (C) 2009 Paraguay Educa, Martin Abente
 # Copyright (C) 2010 Plan Ceibal, Daniel Castelo
+# Copyright (C) 2011 Peter Robinson
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,22 +35,38 @@
 from sugar import env
 from sugar.util import unique_id
 
-
-DEVICE_TYPE_802_3_ETHERNET = 1
-DEVICE_TYPE_802_11_WIRELESS = 2
-DEVICE_TYPE_GSM_MODEM = 3
-DEVICE_TYPE_802_11_OLPC_MESH = 6
-
-DEVICE_STATE_UNKNOWN = 0
-DEVICE_STATE_UNMANAGED = 1
-DEVICE_STATE_UNAVAILABLE = 2
-DEVICE_STATE_DISCONNECTED = 3
-DEVICE_STATE_PREPARE = 4
-DEVICE_STATE_CONFIG = 5
-DEVICE_STATE_NEED_AUTH = 6
-DEVICE_STATE_IP_CONFIG = 7
-DEVICE_STATE_ACTIVATED = 8
-DEVICE_STATE_FAILED = 9
+NM_STATE_UNKNOWN = 0
+NM_STATE_ASLEEP = 10
+NM_STATE_DISCONNECTED = 20
+NM_STATE_DISCONNECTING = 30
+NM_STATE_CONNECTING = 40
+NM_STATE_CONNECTED_LOCAL = 50
+NM_STATE_CONNECTED_SITE = 60
+NM_STATE_CONNECTED_GLOBAL = 70
+
+NM_DEVICE_TYPE_UNKNOWN = 0
+NM_DEVICE_TYPE_ETHERNET = 1
+NM_DEVICE_TYPE_WIFI = 2
+NM_DEVICE_TYPE_UNUSED1 = 3
+NM_DEVICE_TYPE_UNUSED2 = 4
+NM_DEVICE_TYPE_BT = 5
+NM_DEVICE_TYPE_OLPC_MESH = 6
+NM_DEVICE_TYPE_WIMAX = 7
+NM_DEVICE_TYPE_MODEM = 8
+
+NM_DEVICE_STATE_UNKNOWN = 0
+NM_DEVICE_STATE_UNMANAGED = 10
+NM_DEVICE_STATE_UNAVAILABLE = 20
+NM_DEVICE_STATE_DISCONNECTED = 30
+NM_DEVICE_STATE_PREPARE = 40
+NM_DEVICE_STATE_CONFIG = 50
+NM_DEVICE_STATE_NEED_AUTH = 60
+NM_DEVICE_STATE_IP_CONFIG = 70
+NM_DEVICE_STATE_IP_CHECK = 80
+NM_DEVICE_STATE_SECONDARIES = 90
+NM_DEVICE_STATE_ACTIVATED = 100
+NM_DEVICE_STATE_DEACTIVATING = 110
+NM_DEVICE_STATE_FAILED = 120
 
 NM_CONNECTION_TYPE_802_11_WIRELESS = '802-11-wireless'
 NM_CONNECTION_TYPE_GSM = 'gsm'
@@ -57,15 +74,15 @@
 NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0
 NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1
 NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2
-
+NM_ACTIVE_CONNECTION_STATE_DEACTIVATING = 3
 
 NM_DEVICE_STATE_REASON_UNKNOWN = 0
 NM_DEVICE_STATE_REASON_NONE = 1
 NM_DEVICE_STATE_REASON_NOW_MANAGED = 2
 NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3
 NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4
-NM_DEVICE_STATE_REASON_CONFIG_UNAVAILABLE = 5
-NM_DEVICE_STATE_REASON_CONFIG_EXPIRED = 6
+NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5
+NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6
 NM_DEVICE_STATE_REASON_NO_SECRETS = 7
 NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8
 NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9
@@ -100,6 +117,11 @@
 NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38
 NM_DEVICE_STATE_REASON_USER_REQUESTED = 39
 NM_DEVICE_STATE_REASON_CARRIER = 40
+NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41
+NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42
+NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43
+NM_DEVICE_STATE_REASON_BT_FAILED = 44
+NM_DEVICE_STATE_REASON_LAST = 0xFFFF
 
 NM_802_11_AP_FLAGS_NONE = 0x00000000
 NM_802_11_AP_FLAGS_PRIVACY = 0x00000001
@@ -120,24 +142,35 @@
 NM_802_11_MODE_ADHOC = 1
 NM_802_11_MODE_INFRA = 2
 
-NM_802_11_DEVICE_CAP_NONE = 0x00000000
-NM_802_11_DEVICE_CAP_CIPHER_WEP40 = 0x00000001
-NM_802_11_DEVICE_CAP_CIPHER_WEP104 = 0x00000002
-NM_802_11_DEVICE_CAP_CIPHER_TKIP = 0x00000004
-NM_802_11_DEVICE_CAP_CIPHER_CCMP = 0x00000008
-NM_802_11_DEVICE_CAP_WPA = 0x00000010
-NM_802_11_DEVICE_CAP_RSN = 0x00000020
+NM_WIFI_DEVICE_CAP_NONE = 0x00000000
+NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 0x00000001
+NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 0x00000002
+NM_WIFI_DEVICE_CAP_CIPHER_TKIP = 0x00000004
+NM_WIFI_DEVICE_CAP_CIPHER_CCMP = 0x00000008
+NM_WIFI_DEVICE_CAP_WPA = 0x00000010
+NM_WIFI_DEVICE_CAP_RSN = 0x00000020
+
+NM_BT_CAPABILITY_NONE = 0x00000000
+NM_BT_CAPABILITY_DUN = 0x00000001
+NM_BT_CAPABILITY_NAP = 0x00000002
+
+NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000
+NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001
+NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002
+NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004
+NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008
 
-SETTINGS_SERVICE = 'org.freedesktop.NetworkManagerUserSettings'
+SETTINGS_SERVICE = 'org.freedesktop.NetworkManager'
 
 NM_SERVICE = 'org.freedesktop.NetworkManager'
 NM_IFACE = 'org.freedesktop.NetworkManager'
 NM_PATH = '/org/freedesktop/NetworkManager'
 NM_DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device'
-NM_SETTINGS_PATH = '/org/freedesktop/NetworkManagerSettings'
-NM_SETTINGS_IFACE = 'org.freedesktop.NetworkManagerSettings'
-NM_CONNECTION_IFACE = 'org.freedesktop.NetworkManagerSettings.Connection'
-NM_SECRETS_IFACE = 'org.freedesktop.NetworkManagerSettings.Connection.Secrets'
+NM_SETTINGS_PATH = '/org/freedesktop/NetworkManager/Settings'
+NM_SETTINGS_IFACE = 'org.freedesktop.NetworkManager.Settings'
+NM_GETSETTINGS_IFACE = 'org.freedesktop.NetworkManager.Settings.Connection.GetSettings'
+NM_CONNECTION_IFACE = 'org.freedesktop.NetworkManager.Settings.Connection'
+NM_SECRETS_IFACE = 'org.freedesktop.NetworkManager.AgentManager'
 NM_ACCESSPOINT_IFACE = 'org.freedesktop.NetworkManager.AccessPoint'
 NM_ACTIVE_CONN_IFACE = 'org.freedesktop.NetworkManager.Connection.Active'
 
@@ -169,10 +202,10 @@
                 _('The device is no longer managed.'),
             NM_DEVICE_STATE_REASON_CONFIG_FAILED:
                 _('The device could not be readied for configuration.'),
-            NM_DEVICE_STATE_REASON_CONFIG_UNAVAILABLE:
+            NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE:
                 _('IP configuration could not be reserved '
                   '(no available address, timeout, etc).'),
-            NM_DEVICE_STATE_REASON_CONFIG_EXPIRED:
+            NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED:
                 _('The IP configuration is no longer valid.'),
             NM_DEVICE_STATE_REASON_NO_SECRETS:
                 _('Secrets were required, but not provided.'),
@@ -244,11 +277,48 @@
             NM_DEVICE_STATE_REASON_USER_REQUESTED:
                 _('A user or client requested the disconnection.'),
             NM_DEVICE_STATE_REASON_CARRIER:
-                _("The device's carrier/link changed.")}
+                _("The device's carrier/link changed."),
+            NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED:
+                _("The device's existing connection was assumed."),
+            NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE:
+                _("The supplicant is now available."),
+            NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND:
+                _("The modem could not be found."),
+            NM_DEVICE_STATE_REASON_BT_FAILED:
+                _("The Bluetooth connection failed or timed out."),
+            NM_DEVICE_STATE_REASON_LAST:
+                _("Unused."),
+        }
 
     return _nm_device_state_reason_description[reason]
 
 
+def get_nm_state_by_reason(reason):
+    global _nm_state_reason_description
+
+    if _nm_state_reason_description is None:
+        _nm_state_reason_description = {
+            NM_STATE_UNKNOWN:
+                _('networking state is unknown.'),
+            NM_STATE_ASLEEP:
+                _('networking is not enabled.'),
+            NM_STATE_DISCONNECTED:
+                _('there is no active network connection.'),
+            NM_STATE_DISCONNECTING:
+                _('network connections are being cleaned up.'),
+            NM_STATE_CONNECTING:
+                _('a network connection is being started.'),
+            NM_STATE_CONNECTED_LOCAL:
+                _('there is only local IPv4 and/or IPv6 connectivity.'),
+            NM_STATE_CONNECTED_SITE:
+                _('there is only site-wide IPv4 and/or IPv6 connectivity.'),
+            NM_STATE_CONNECTED_GLOBAL:
+                _('there is global IPv4 and/or IPv6 Internet connectivity.'),
+        }
+
+    return _nm_state_reason_description[reason]
+
+
 def frequency_to_channel(frequency):
     """Returns the channel matching a given radio channel frequency. If a
     frequency is not in the dictionary channel 1 will be returned.