diff --git a/src/common/connection.py b/src/common/connection.py index e3610cc7525da923db16160fd7c401d6b2d15516..90ef64c00d0e3f9c339af5724ad456d29093678c 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -561,7 +561,16 @@ class Connection(ConnectionHandlers): def del_privacy_list(self, privacy_list): if not self.connection: return - common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list) + def _on_del_privacy_list_result(result): + if result: + self.dispatch('PRIVACY_LIST_REMOVED', privacy_list) + else: + self.dispatch('ERROR', (_('Error while removing privacy list'), + _('Privacy list %s has not been removed. It is maybe active in ' + 'one of your connected resources. Desactivate it and try ' + 'again.') % privacy_list)) + common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list, + _on_del_privacy_list_result) def get_privacy_list(self, title): if not self.connection: diff --git a/src/common/xmpp/features_nb.py b/src/common/xmpp/features_nb.py index 0b754e1ef085c3470ce6a4b9d5acd57b23709dd2..61e54ce7d2b7cebf7bc0b680026b0a2aec8a6096 100644 --- a/src/common/xmpp/features_nb.py +++ b/src/common/xmpp/features_nb.py @@ -249,7 +249,7 @@ def setPrivacyList(disp, listname, tags): item_tag.setTag(child_tag) _on_default_response(disp, iq, None) -def delPrivacyList(disp,listname): +def delPrivacyList(disp,listname,cb=None): """ Deletes privacy list 'listname'. Returns true on success.""" iq = Iq('set',NS_PRIVACY,payload=[Node('list',{'name':listname})]) - _on_default_response(disp, iq, None) + _on_default_response(disp, iq, cb) diff --git a/src/dialogs.py b/src/dialogs.py index 4d28fe9636fb6820f4c9afead30632ff28c2866b..50bb866da34a82c202a46b9319dcd2d68e5f70a8 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2187,6 +2187,8 @@ class PrivacyListsWindow: active_list = self.privacy_lists_save[ self.list_of_privacy_lists_combobox.get_active()] gajim.connections[self.account].del_privacy_list(active_list) + + def privacy_list_removed(self, active_list): self.privacy_lists_save.remove(active_list) self.privacy_lists_received({'lists': self.privacy_lists_save}) diff --git a/src/gajim.py b/src/gajim.py index 77a7ed3218d69e589979ad604f1ad0b7de2090e9..f156509a5b887a849ecabcb2078a83fdab17cdc7 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1621,6 +1621,13 @@ class Interface: if win.startswith('privacy_list_'): self.instances[account][win].check_active_default(data) + def handle_event_privacy_list_removed(self, account, name): + # ('PRIVACY_LISTS_REMOVED', account, name) + if not self.instances.has_key(account): + return + if self.instances[account].has_key('privacy_lists'): + self.instances[account]['privacy_lists'].privacy_list_removed(name) + def handle_event_zc_name_conflict(self, account, data): dlg = dialogs.InputDialog(_('Username Conflict'), _('Please type a new username for your local account'), @@ -1946,6 +1953,7 @@ class Interface: 'PRIVACY_LIST_RECEIVED': self.handle_event_privacy_list_received, 'PRIVACY_LISTS_ACTIVE_DEFAULT': \ self.handle_event_privacy_lists_active_default, + 'PRIVACY_LIST_REMOVED': self.handle_event_privacy_list_removed, 'ZC_NAME_CONFLICT': self.handle_event_zc_name_conflict, } gajim.handlers = self.handlers