Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2011-03-02 15:21:40 (GMT)
committer Simon Schampijer <simon@schampijer.de>2011-03-02 15:21:40 (GMT)
commit582f9df1acbff8c71d897f37a4a4e98d4830fd3f (patch)
treec9587306ec572626162db638fb517ad0119413c4
parent06e3c9898c90fe180df602ceca984d2f5b8b6bdb (diff)
Sugar Ad-hoc network: reconnect after suspend SL #2187
Setting the 'autoconnect' property for the connection will let NM do the reconnection when the device is up. If the Sugar Ad-hoc network is around it will automatically connect to it. The connection is not stored after logging out of Sugar. The autoconnect functionality inside Sugar is still needed for the cases when we log into Sugar, after a timeout we will connect to an exisiting Ad-hoc network or will default to the Sugar Ad-hoc network on channel 1. I increased the timeout to 60 seconds because during testing I found to get more reliable results like that. Signed-off-by: Simon Schampijer <simon@laptop.org> Acked-By: Sascha Silbe <silbe@activitycentral.com>
-rw-r--r--src/jarabe/model/adhoc.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/jarabe/model/adhoc.py b/src/jarabe/model/adhoc.py
index 3f4587a..647bd8e 100644
--- a/src/jarabe/model/adhoc.py
+++ b/src/jarabe/model/adhoc.py
@@ -58,7 +58,7 @@ class AdHocManager(gobject.GObject):
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
}
- _AUTOCONNECT_TIMEOUT = 30
+ _AUTOCONNECT_TIMEOUT = 60
_CHANNEL_1 = 1
_CHANNEL_6 = 6
_CHANNEL_11 = 11
@@ -141,28 +141,21 @@ class AdHocManager(gobject.GObject):
return len(network.get_settings().connections) > 0
def autoconnect(self):
- """Autoconnect to an Ad-hoc network"""
- if self._device_state != network.DEVICE_STATE_DISCONNECTED:
- return
- elif self._have_configured_connections():
- self._autoconnect_adhoc_timer()
- else:
- self._autoconnect_adhoc()
-
- def _autoconnect_adhoc_timer(self):
"""Start a timer which basically looks for 30 seconds of inactivity
on the device, then does autoconnect to an Ad-hoc network.
"""
if self._idle_source != 0:
gobject.source_remove(self._idle_source)
- self._idle_source = gobject.timeout_add_seconds( \
- self._AUTOCONNECT_TIMEOUT, self.__idle_check_cb)
+ self._idle_source = gobject.timeout_add_seconds(
+ 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.DEVICE_STATE_DISCONNECTED:
logging.debug('Connect to Ad-hoc network due to inactivity.')
self._autoconnect_adhoc()
+ else:
+ logging.debug('autoconnect Sugar Ad-hoc: already connected')
return False
def _autoconnect_adhoc(self):
@@ -196,6 +189,7 @@ class AdHocManager(gobject.GObject):
settings.connection.id = name
settings.connection.uuid = unique_id()
settings.connection.type = '802-11-wireless'
+ settings.connection.autoconnect = True
settings.wireless.ssid = dbus.ByteArray(name)
settings.wireless.band = 'bg'
settings.wireless.channel = channel