summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.py2
-rw-r--r--src/roster.py2
-rw-r--r--src/tabs.py41
3 files changed, 42 insertions, 3 deletions
diff --git a/src/core.py b/src/core.py
index c3b3510d..47ef1696 100644
--- a/src/core.py
+++ b/src/core.py
@@ -591,6 +591,8 @@ class Core(object):
contact.set_subscription(item.attrib['subscription'])
groups = item.findall('{jabber:iq:roster}group')
roster.edit_groups_of_contact(contact, [group.text for group in groups])
+ if item.attrib['subscription'] == 'remove':
+ roster.remove_contact(contact.get_bare_jid())
if isinstance(self.current_tab(), tabs.RosterInfoTab):
self.refresh_window()
diff --git a/src/roster.py b/src/roster.py
index 1fd1099d..a299ba12 100644
--- a/src/roster.py
+++ b/src/roster.py
@@ -45,7 +45,7 @@ class Roster(object):
"""
contact = self.get_contact_by_jid(jid)
for group in contact._groups:
- group.remove_contact_from_group(contact)
+ self.remove_contact_from_group(group, contact)
del self._contacts[jid]
def get_contact_len(self):
diff --git a/src/tabs.py b/src/tabs.py
index f1efdc72..e3418491 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -752,7 +752,9 @@ class RosterInfoTab(Tab):
self.key_func["s"] = self.start_search
self.key_func["S"] = self.start_search_slow
self.commands['deny'] = (self.command_deny, _("Usage: /deny [jid]\nDeny: Use this command to remove and deny your presence to the provided JID (or the selected contact in your roster), who is asking you to be in his/here roster"), self.completion_deny)
- self.commands['accept'] = (self.command_accept, _("Usage: /accpet [jid]\nAccept: Use this command to authorize the provided JID (or the selected contact in your roster), to see your presence, and to ask to subscribe to it (mutual presence subscription)."), self.completion_deny)
+ self.commands['accept'] = (self.command_accept, _("Usage: /accept [jid]\nAccept: Use this command to authorize the provided JID (or the selected contact in your roster), to see your presence, and to ask to subscribe to it (mutual presence subscription)."), self.completion_deny)
+ self.commands['add'] = (self.command_add, _("Usage: /add <jid>\Add: Use this command to add the specified JID to your roster. The reverse authorization will automatically be accepted if the remote JID accepts your subscription, leading to a mutual presence subscription."), None)
+ self.commands['remove'] = (self.command_remove, _("Usage: /remove [jid]\Remove: Use this command to remove the specified JID from your roster. This wil unsubscribe you from its presence, cancel its subscription to yours, and remove the item from your roster"), self.completion_remove)
self.resize()
def resize(self):
@@ -785,11 +787,46 @@ class RosterInfoTab(Tab):
self.core.information('No subscription to deny')
return
else:
- jid = args[0]
+ jid = JID(args[0]).bare
self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribed')
if self.core.xmpp.update_roster(jid, subscription='remove'):
roster.remove_contact(jid)
+ def command_add(self, args):
+ """
+ Add the specified JID to the roster, and set automatically
+ accept the reverse subscription
+ """
+ jid = JID(args.strip()).bare
+ if not jid:
+ return
+ self.core.xmpp.sendPresence(pto=jid, ptype='subscribe')
+
+ def command_remove(self, args):
+ """
+ Remove the specified JID from the roster. i.e. : unsubscribe
+ from its presence, and cancel its subscription to our.
+ """
+ if args.strip():
+ jid = JID(args.strip()).bare
+ else:
+ item = self.roster_win.selected_row
+ if isinstance(item, Contact):
+ jid = item.get_bare_jid()
+ else:
+ self.core.information('No roster item to remove')
+ return
+ self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribe')
+ self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribed')
+ self.core.xmpp.del_roster_item(jid=jid)
+
+ def completion_remove(self, the_input):
+ """
+ From with any JID presence in the roster
+ """
+ jids = [contact.get_bare_jid() for contact in roster.get_contacts()]
+ the_input.auto_completion(jids, '')
+
def completion_deny(self, the_input):
"""
Complete the first argument from the list of the