~kamstrup/zeitgeist/network-manager-state-fix

« back to all changes in this revision

Viewing changes to _zeitgeist/engine/extensions/storagemonitor.py

  • Committer: Mikkel Kamstrup Erlandsen
  • Author(s): Mikkel Kamstrup Erlandsen
  • Date: 2011-09-05 12:09:36 UTC
  • Revision ID: mikkel.kamstrup@gmail.com-20110905120936-020xniqy4jdzts7z
Update the storagemonitor.py extension to also work with NetworkManager API version >= 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
303
303
        NM_IFACE = "org.freedesktop.NetworkManager"
304
304
        NM_OBJECT_PATH = "/org/freedesktop/NetworkManager"
305
305
        
306
 
        NM_STATE_UNKNOWN = 0
307
 
        NM_STATE_ASLEEP = 1
308
 
        NM_STATE_CONNECTING = 2
309
 
        NM_STATE_CONNECTED = 3
310
 
        NM_STATE_DISCONNECTED = 4
 
306
        # NM 0.9 broke API so we have to check for two possible values for the state
 
307
        NM_STATE_CONNECTED_PRE_09 = 3
 
308
        NM_STATE_CONNECTED_POST_09 = 70
311
309
        
312
310
        def __init__ (self, on_network_up, on_network_down):
313
311
                log.debug("Creating NetworkManager network monitor")
335
333
                
336
334
        def _on_state_changed(self, state):
337
335
                log.debug("NetworkManager network state: %s" % state)
338
 
                if state == NMNetworkMonitor.NM_STATE_CONNECTED:
 
336
                if state == NMNetworkMonitor.NM_STATE_CONNECTED_PRE_09 or state == NMNetworkMonitor.NM_STATE_CONNECTED_POST_09:
339
337
                        self._up ()
340
338
                else:
341
339
                        self._down()