correctly cleanup ged handlers when removing an account
This commit is contained in:
parent
0ac61706d8
commit
a6cb79b681
|
@ -719,11 +719,14 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self._nec_agent_info_received)
|
||||
# END __init__
|
||||
|
||||
def __del__(self):
|
||||
def cleanup(self):
|
||||
ConnectionHandlers.cleanup(self)
|
||||
gajim.ged.remove_event_handler('privacy-list-received', ged.CORE,
|
||||
self._nec_privacy_list_received)
|
||||
gajim.ged.remove_event_handler('agent-info-error-received', ged.CORE,
|
||||
self._nec_agent_info_error_received)
|
||||
gajim.ged.remove_event_handler('agent-info-received', ged.CORE,
|
||||
self._nec_agent_info_received)
|
||||
|
||||
def get_config_values_or_default(self):
|
||||
if gajim.config.get_per('accounts', self.name, 'keep_alives_enabled'):
|
||||
|
|
|
@ -766,6 +766,16 @@ class ConnectionHandlersBase:
|
|||
gajim.ged.register_event_handler('decrypted-message-received', ged.CORE,
|
||||
self._nec_decrypted_message_received)
|
||||
|
||||
def cleanup(self):
|
||||
gajim.ged.remove_event_handler('iq-error-received', ged.CORE,
|
||||
self._nec_iq_error_received)
|
||||
gajim.ged.remove_event_handler('presence-received', ged.CORE,
|
||||
self._nec_presence_received)
|
||||
gajim.ged.remove_event_handler('message-received', ged.CORE,
|
||||
self._nec_message_received)
|
||||
gajim.ged.remove_event_handler('decrypted-message-received', ged.CORE,
|
||||
self._nec_decrypted_message_received)
|
||||
|
||||
def _nec_iq_error_received(self, obj):
|
||||
if obj.conn.name != self.name:
|
||||
return
|
||||
|
@ -1265,6 +1275,48 @@ ConnectionJingle, ConnectionIBBytestream):
|
|||
gajim.ged.register_event_handler('agent-removed', ged.CORE,
|
||||
self._nec_agent_removed)
|
||||
|
||||
def cleanup(self):
|
||||
ConnectionHandlersBase.cleanup(self)
|
||||
ConnectionCaps.cleanup(self)
|
||||
ConnectionArchive.cleanup(self)
|
||||
ConnectionPubSub.cleanup(self)
|
||||
gajim.ged.remove_event_handler('http-auth-received', ged.CORE,
|
||||
self._nec_http_auth_received)
|
||||
gajim.ged.remove_event_handler('version-request-received', ged.CORE,
|
||||
self._nec_version_request_received)
|
||||
gajim.ged.remove_event_handler('last-request-received', ged.CORE,
|
||||
self._nec_last_request_received)
|
||||
gajim.ged.remove_event_handler('time-request-received', ged.CORE,
|
||||
self._nec_time_request_received)
|
||||
gajim.ged.remove_event_handler('time-revised-request-received',
|
||||
ged.CORE, self._nec_time_revised_request_received)
|
||||
gajim.ged.remove_event_handler('roster-set-received',
|
||||
ged.CORE, self._nec_roster_set_received)
|
||||
gajim.ged.remove_event_handler('private-storage-bookmarks-received',
|
||||
ged.CORE, self._nec_private_storate_bookmarks_received)
|
||||
gajim.ged.remove_event_handler('private-storage-rosternotes-received',
|
||||
ged.CORE, self._nec_private_storate_rosternotes_received)
|
||||
gajim.ged.remove_event_handler('roster-received', ged.CORE,
|
||||
self._nec_roster_received)
|
||||
gajim.ged.remove_event_handler('iq-error-received', ged.CORE,
|
||||
self._nec_iq_error_received)
|
||||
gajim.ged.remove_event_handler('gmail-new-mail-received', ged.CORE,
|
||||
self._nec_gmail_new_mail_received)
|
||||
gajim.ged.remove_event_handler('ping-received', ged.CORE,
|
||||
self._nec_ping_received)
|
||||
gajim.ged.remove_event_handler('subscribe-presence-received',
|
||||
ged.CORE, self._nec_subscribe_presence_received)
|
||||
gajim.ged.remove_event_handler('subscribed-presence-received',
|
||||
ged.CORE, self._nec_subscribed_presence_received)
|
||||
gajim.ged.remove_event_handler('subscribed-presence-received',
|
||||
ged.POSTGUI, self._nec_subscribed_presence_received_end)
|
||||
gajim.ged.remove_event_handler('unsubscribed-presence-received',
|
||||
ged.CORE, self._nec_unsubscribed_presence_received)
|
||||
gajim.ged.remove_event_handler('unsubscribed-presence-received',
|
||||
ged.POSTGUI, self._nec_unsubscribed_presence_received_end)
|
||||
gajim.ged.remove_event_handler('agent-removed', ged.CORE,
|
||||
self._nec_agent_removed)
|
||||
|
||||
def build_http_auth_answer(self, iq_obj, answer):
|
||||
if not self.connection or self.connected < 2:
|
||||
return
|
||||
|
|
|
@ -46,6 +46,11 @@ class ConnectionArchive:
|
|||
'archiving-preferences-changed-received', ged.CORE,
|
||||
self._nec_archiving_changed_received)
|
||||
|
||||
def cleanup(self):
|
||||
gajim.ged.remove_event_handler(
|
||||
'archiving-preferences-changed-received', ged.CORE,
|
||||
self._nec_archiving_changed_received)
|
||||
|
||||
def request_message_archiving_preferences(self):
|
||||
iq_ = common.xmpp.Iq('get')
|
||||
iq_.setTag('pref', namespace=common.xmpp.NS_ARCHIVE)
|
||||
|
|
|
@ -85,6 +85,10 @@ class ConnectionBytestream:
|
|||
gajim.ged.register_event_handler('file-request-received', ged.GUI1,
|
||||
self._nec_file_request_received)
|
||||
|
||||
def cleanup(self):
|
||||
gajim.ged.remove_event_handler('file-request-received', ged.GUI1,
|
||||
self._nec_file_request_received)
|
||||
|
||||
def _ft_get_our_jid(self):
|
||||
our_jid = gajim.get_jid_from_account(self.name)
|
||||
resource = self.server_resource
|
||||
|
|
|
@ -46,6 +46,12 @@ class ConnectionCaps(object):
|
|||
gajim.ged.register_event_handler('agent-info-received', ged.GUI1,
|
||||
self._nec_agent_info_received_caps)
|
||||
|
||||
def cleanup(self):
|
||||
gajim.ged.remove_event_handler('caps-presence-received', ged.GUI1,
|
||||
self._nec_caps_presence_received)
|
||||
gajim.ged.remove_event_handler('agent-info-received', ged.GUI1,
|
||||
self._nec_agent_info_received_caps)
|
||||
|
||||
def caps_change_account_name(self, new_name):
|
||||
self._account = new_name
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@ class ConnectionPubSub:
|
|||
gajim.ged.register_event_handler('pubsub-bookmarks-received',
|
||||
ged.CORE, self._nec_pubsub_bookmarks_received)
|
||||
|
||||
def cleanup(self):
|
||||
gajim.ged.remove_event_handler('pubsub-bookmarks-received',
|
||||
ged.CORE, self._nec_pubsub_bookmarks_received)
|
||||
|
||||
def send_pb_subscription_query(self, jid, cb, *args, **kwargs):
|
||||
if not self.connection or self.connected < 2:
|
||||
return
|
||||
|
@ -212,4 +216,4 @@ class ConnectionPubSub:
|
|||
id_ = self.connection.getAnID()
|
||||
query.setID(id_)
|
||||
self.awaiting_answers[id_] = (connection_handlers.PEP_CONFIG,)
|
||||
self.connection.send(query)
|
||||
self.connection.send(query)
|
||||
|
|
|
@ -3005,6 +3005,7 @@ class RemoveAccountWindow:
|
|||
gajim.interface.roster.close_all(self.account, force=True)
|
||||
if self.account in gajim.connections:
|
||||
gajim.connections[self.account].disconnect(on_purpose=True)
|
||||
gajim.connections[self.account].cleanup()
|
||||
del gajim.connections[self.account]
|
||||
gajim.logger.remove_roster(gajim.get_jid_from_account(self.account))
|
||||
gajim.config.del_per('accounts', self.account)
|
||||
|
|
Loading…
Reference in New Issue