Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits:
-
3213b5c8
by lovetox at 2021-03-06T16:30:30+01:00
3 changed files:
Changes:
| ... | ... | @@ -116,7 +116,10 @@ def _process_roster_push(self, _con, _stanza, properties): |
| 116 | 116 |
self._log.info('Push received')
|
| 117 | 117 |
|
| 118 | 118 |
item = properties.roster.item
|
| 119 |
- self._roster[item.jid] = item
|
|
| 119 |
+ if item.subscription == 'remove':
|
|
| 120 |
+ self._roster.pop(item.jid)
|
|
| 121 |
+ else:
|
|
| 122 |
+ self._roster[item.jid] = item
|
|
| 120 | 123 |
|
| 121 | 124 |
self._store_roster()
|
| 122 | 125 |
|
| ... | ... | @@ -522,18 +522,18 @@ def _block_contact(report=None): |
| 522 | 522 |
modal=False).show()
|
| 523 | 523 |
|
| 524 | 524 |
def remove_contact(self, account, jid):
|
| 525 |
+ client = app.get_client(account)
|
|
| 526 |
+ |
|
| 525 | 527 |
def _remove_contact():
|
| 526 | 528 |
self.remove_chat(account, jid)
|
| 527 |
- roster = self._account_pages[account].get_roster()
|
|
| 528 |
- roster.remove_contact(jid)
|
|
| 529 |
+ client.get_module('Roster').delete_item(jid)
|
|
| 529 | 530 |
|
| 530 |
- client = app.get_client(account)
|
|
| 531 | 531 |
contact = client.get_module('Contacts').get_contact(jid)
|
| 532 | 532 |
sec_text = _('You are about to remove %(name)s (%(jid)s) from '
|
| 533 | 533 |
'your contact list.\n') % {
|
| 534 | 534 |
'name': contact.name,
|
| 535 | 535 |
'jid': jid}
|
| 536 |
- # TODO: ConfirmationCheckDialog for subscription decision?
|
|
| 536 |
+ |
|
| 537 | 537 |
ConfirmationDialog(
|
| 538 | 538 |
_('Remove Contact'),
|
| 539 | 539 |
_('Remove contact from contact list'),
|
| ... | ... | @@ -26,10 +26,7 @@ |
| 26 | 26 |
log = logging.getLogger('gajim.gui.roster')
|
| 27 | 27 |
|
| 28 | 28 |
|
| 29 |
-HANDLED_EVENTS = [
|
|
| 30 |
- 'presence-received',
|
|
| 31 |
-]
|
|
| 32 |
- |
|
| 29 |
+HANDLED_EVENTS = []
|
|
| 33 | 30 |
|
| 34 | 31 |
DEFAULT_GROUP = _('Contacts')
|
| 35 | 32 |
|
| ... | ... | @@ -354,7 +351,11 @@ def _on_roster_received(self, _event): |
| 354 | 351 |
@event_filter(['account'])
|
| 355 | 352 |
def _on_roster_push(self, event):
|
| 356 | 353 |
contact = self._get_contact(event.item.jid)
|
| 357 |
- self._add_or_update_contact(contact)
|
|
| 354 |
+ |
|
| 355 |
+ if event.item.subscription == 'remove':
|
|
| 356 |
+ self._remove_contact(contact)
|
|
| 357 |
+ else:
|
|
| 358 |
+ self._add_or_update_contact(contact)
|
|
| 358 | 359 |
|
| 359 | 360 |
def _get_current_groups(self, jid):
|
| 360 | 361 |
groups = set()
|
| ... | ... | @@ -560,18 +561,10 @@ def clear(self): |
| 560 | 561 |
self._group_refs = {}
|
| 561 | 562 |
self._store.clear()
|
| 562 | 563 |
|
| 563 |
- def _on_presence_received(self, _event):
|
|
| 564 |
- pass
|
|
| 565 |
- |
|
| 566 | 564 |
def process_event(self, event):
|
| 567 | 565 |
if event.name not in HANDLED_EVENTS:
|
| 568 | 566 |
return
|
| 569 | 567 |
|
| 570 |
- if event.name == 'presence-received':
|
|
| 571 |
- self._on_presence_received(event)
|
|
| 572 |
- else:
|
|
| 573 |
- log.warning('Unhandled Event: %s', event.name)
|
|
| 574 |
- |
|
| 575 | 568 |
def _on_destroy(self, _roster):
|
| 576 | 569 |
self._remove_actions()
|
| 577 | 570 |
self._contact_refs = {}
|