move enable_location_listener to location_listener.py directly

This commit is contained in:
Yann Leboulanger 2009-12-07 23:40:28 +01:00
parent 869ad9ec2b
commit 108aaa0027
3 changed files with 14 additions and 13 deletions

View File

@ -78,6 +78,7 @@ class LocationListener:
accuracy) accuracy)
def start(self): def start(self):
self.get_data()
bus = dbus.SessionBus() bus = dbus.SessionBus()
# Geoclue # Geoclue
bus.add_signal_receiver(self._on_geoclue_address_changed, bus.add_signal_receiver(self._on_geoclue_address_changed,
@ -114,3 +115,11 @@ class LocationListener:
continue continue
gajim.connections[acct].send_location(self._data) gajim.connections[acct].send_location(self._data)
gajim.connections[acct].location_info = self._data gajim.connections[acct].location_info = self._data
def enable():
listener = LocationListener.get()
listener.start()
def disable():
listener = LocationListener.get()
listener.shut_down()

View File

@ -50,7 +50,7 @@ from common import gajim
from common import dbus_support from common import dbus_support
if dbus_support.supported: if dbus_support.supported:
from music_track_listener import MusicTrackListener from music_track_listener import MusicTrackListener
from common.location_listener import LocationListener from common import location_listener
import dbus import dbus
import gtkgui_helpers import gtkgui_helpers
@ -1551,7 +1551,7 @@ class Interface:
# enable location listener # enable location listener
if gajim.connections[account].pep_supported and dbus_support.supported \ if gajim.connections[account].pep_supported and dbus_support.supported \
and gajim.config.get_per('accounts', account, 'publish_location'): and gajim.config.get_per('accounts', account, 'publish_location'):
self.enable_location_listener() location_listener.enable()
def handle_event_metacontacts(self, account, tags_list): def handle_event_metacontacts(self, account, tags_list):
gajim.contacts.define_metacontacts(account, tags_list) gajim.contacts.define_metacontacts(account, tags_list)
@ -2790,15 +2790,6 @@ class Interface:
listener.disconnect(self.music_track_changed_signal) listener.disconnect(self.music_track_changed_signal)
self.music_track_changed_signal = None self.music_track_changed_signal = None
def enable_location_listener(self):
listener = LocationListener.get()
listener.get_data()
listener.start()
def disable_location_listener(self):
listener = LocationListener.get()
listener.shut_down()
def music_track_changed(self, unused_listener, music_track_info, account=None): def music_track_changed(self, unused_listener, music_track_info, account=None):
if not account: if not account:
accounts = gajim.connections.keys() accounts = gajim.connections.keys()

View File

@ -59,6 +59,7 @@ from common import helpers
from common.exceptions import GajimGeneralException from common.exceptions import GajimGeneralException
from common import i18n from common import i18n
from common import pep from common import pep
from common import location_listener
from message_window import MessageWindowMgr from message_window import MessageWindowMgr
@ -3437,7 +3438,7 @@ class RosterWindow:
active = widget.get_active() active = widget.get_active()
gajim.config.set_per('accounts', account, 'publish_location', active) gajim.config.set_per('accounts', account, 'publish_location', active)
if active: if active:
gajim.interface.enable_location_listener() location_listener.enable()
else: else:
gajim.connections[account].retract_location() gajim.connections[account].retract_location()
# disable music listener only if no other account uses it # disable music listener only if no other account uses it
@ -3445,7 +3446,7 @@ class RosterWindow:
if gajim.config.get_per('accounts', acc, 'publish_location'): if gajim.config.get_per('accounts', acc, 'publish_location'):
break break
else: else:
gajim.interface.disable_location_listener() location_listener.disable()
helpers.update_optional_features(account) helpers.update_optional_features(account)