Commit dacb83d2 authored by Dan Pascu's avatar Dan Pascu

Do not unnecessarily instantiate the NotificationCenter

parent 163de5a7
...@@ -332,8 +332,7 @@ class GoogleContactsManager(object): ...@@ -332,8 +332,7 @@ class GoogleContactsManager(object):
def _NH_SIPApplicationWillStart(self, notification): def _NH_SIPApplicationWillStart(self, notification):
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
notification_center = NotificationCenter() notification.center.add_observer(self, name='CFGSettingsObjectDidChange', sender=settings)
notification_center.add_observer(self, name='CFGSettingsObjectDidChange', sender=settings)
authorization_token = settings.google_contacts.authorization_token authorization_token = settings.google_contacts.authorization_token
if authorization_token: if authorization_token:
call_in_gui_thread(self.contact_model.addGroup, self.contact_model.google_contacts_group) call_in_gui_thread(self.contact_model.addGroup, self.contact_model.google_contacts_group)
...@@ -342,8 +341,7 @@ class GoogleContactsManager(object): ...@@ -342,8 +341,7 @@ class GoogleContactsManager(object):
self.remove_group() self.remove_group()
def _NH_SIPApplicationWillEnd(self, notification): def _NH_SIPApplicationWillEnd(self, notification):
notification_center = NotificationCenter() notification.center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings())
notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings())
if self.greenlet is not None: if self.greenlet is not None:
api.kill(self.greenlet, api.GreenletExit()) api.kill(self.greenlet, api.GreenletExit())
......
...@@ -542,9 +542,8 @@ class MainWindow(base_class, ui_class): ...@@ -542,9 +542,8 @@ class MainWindow(base_class, ui_class):
def _NH_SIPApplicationDidStart(self, notification): def _NH_SIPApplicationDidStart(self, notification):
self.load_audio_devices() self.load_audio_devices()
notification_center = NotificationCenter() notification.center.add_observer(self, name='CFGSettingsObjectDidChange')
notification_center.add_observer(self, name='CFGSettingsObjectDidChange') notification.center.add_observer(self, name='AudioDevicesDidChange')
notification_center.add_observer(self, name='AudioDevicesDidChange')
def _NH_AudioDevicesDidChange(self, notification): def _NH_AudioDevicesDidChange(self, notification):
for action in self.output_device_menu.actions(): for action in self.output_device_menu.actions():
......
...@@ -1276,9 +1276,8 @@ class PreferencesWindow(base_class, ui_class): ...@@ -1276,9 +1276,8 @@ class PreferencesWindow(base_class, ui_class):
def _NH_SIPApplicationDidStart(self, notification): def _NH_SIPApplicationDidStart(self, notification):
self._sync_defaults() self._sync_defaults()
self.load_settings() self.load_settings()
notification_center = NotificationCenter() notification.center.add_observer(self, name='AudioDevicesDidChange')
notification_center.add_observer(self, name='AudioDevicesDidChange') notification.center.add_observer(self, name='CFGSettingsObjectDidChange')
notification_center.add_observer(self, name='CFGSettingsObjectDidChange')
def _NH_AudioDevicesDidChange(self, notification): def _NH_AudioDevicesDidChange(self, notification):
self.load_audio_devices() self.load_audio_devices()
......
...@@ -427,8 +427,7 @@ class SessionItem(QObject): ...@@ -427,8 +427,7 @@ class SessionItem(QObject):
digit_map = {'*': 'star'} digit_map = {'*': 'star'}
filename = 'sounds/dtmf_%s_tone.wav' % digit_map.get(notification.data.digit, notification.data.digit) filename = 'sounds/dtmf_%s_tone.wav' % digit_map.get(notification.data.digit, notification.data.digit)
player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get(filename)) player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get(filename))
notification_center = NotificationCenter() notification.center.add_observer(self, sender=player)
notification_center.add_observer(self, sender=player)
SIPApplication.voice_audio_bridge.add(player) SIPApplication.voice_audio_bridge.add(player)
player.start() player.start()
...@@ -440,8 +439,7 @@ class SessionItem(QObject): ...@@ -440,8 +439,7 @@ class SessionItem(QObject):
def _NH_DNSLookupDidSucceed(self, notification): def _NH_DNSLookupDidSucceed(self, notification):
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
notification_center = NotificationCenter() notification.center.remove_observer(self, sender=notification.sender)
notification_center.remove_observer(self, sender=notification.sender)
if self.pending_removal: if self.pending_removal:
return return
streams = [] streams = []
...@@ -459,8 +457,7 @@ class SessionItem(QObject): ...@@ -459,8 +457,7 @@ class SessionItem(QObject):
self.session.connect(ToHeader(self.uri), routes, streams) self.session.connect(ToHeader(self.uri), routes, streams)
def _NH_DNSLookupDidFail(self, notification): def _NH_DNSLookupDidFail(self, notification):
notification_center = NotificationCenter() notification.center.remove_observer(self, sender=notification.sender)
notification_center.remove_observer(self, sender=notification.sender)
if self.pending_removal: if self.pending_removal:
return return
self.audio_stream = None self.audio_stream = None
...@@ -632,12 +629,10 @@ class SessionItem(QObject): ...@@ -632,12 +629,10 @@ class SessionItem(QObject):
self._cleanup() self._cleanup()
def _NH_WavePlayerDidFail(self, notification): def _NH_WavePlayerDidFail(self, notification):
notification_center = NotificationCenter() notification.center.remove_observer(self, sender=notification.sender)
notification_center.remove_observer(self, sender=notification.sender)
def _NH_WavePlayerDidEnd(self, notification): def _NH_WavePlayerDidEnd(self, notification):
notification_center = NotificationCenter() notification.center.remove_observer(self, sender=notification.sender)
notification_center.remove_observer(self, sender=notification.sender)
class Conference(object): class Conference(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment