Commit 6bb94cdf authored by louiz’'s avatar louiz’

Displays the subscription and Ask states in the roster

parent f7102ae3
...@@ -147,7 +147,7 @@ class Contact(object): ...@@ -147,7 +147,7 @@ class Contact(object):
def set_subscription(self, sub): def set_subscription(self, sub):
self._subscription = sub self._subscription = sub
def get_subscription(self, sub): def get_subscription(self):
return self._subscription return self._subscription
def get_nb_resources(self): def get_nb_resources(self):
......
...@@ -757,6 +757,7 @@ class RosterInfoTab(Tab): ...@@ -757,6 +757,7 @@ class RosterInfoTab(Tab):
self.key_func["o"] = self.toggle_offline_show self.key_func["o"] = self.toggle_offline_show
self.key_func["s"] = self.start_search self.key_func["s"] = self.start_search
self.key_func["S"] = self.start_search_slow 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.resize() self.resize()
def resize(self): def resize(self):
...@@ -776,6 +777,11 @@ class RosterInfoTab(Tab): ...@@ -776,6 +777,11 @@ class RosterInfoTab(Tab):
not self.input.help_message: not self.input.help_message:
self.complete_commands(self.input) self.complete_commands(self.input)
def command_deny(self, args):
"""
Denies a JID from our roster
"""
def refresh(self, tabs, informations, roster): def refresh(self, tabs, informations, roster):
if not self.visible: if not self.visible:
return return
......
...@@ -1268,13 +1268,13 @@ class RosterWin(Win): ...@@ -1268,13 +1268,13 @@ class RosterWin(Win):
else: else:
presence = resource.get_presence() presence = resource.get_presence()
folder = '[+]' if contact._folded else '[-]' folder = '[+]' if contact._folded else '[-]'
nb = '(%s)' % (contact.get_nb_resources(),) nb = ' (%s)' % (contact.get_nb_resources(),)
color = RosterWin.color_show[presence] color = RosterWin.color_show[presence]
if contact.get_name(): if contact.get_name():
display_name = '%s (%s) %s' % (contact.get_name(), display_name = '%s (%s)%s' % (contact.get_name(),
contact.get_bare_jid(), nb,) contact.get_bare_jid(), nb,)
else: else:
display_name = '%s %s' % (contact.get_bare_jid(), nb,) display_name = '%s%s' % (contact.get_bare_jid(), nb,)
self.addstr(y, 1, " ", curses.color_pair(color)) self.addstr(y, 1, " ", curses.color_pair(color))
if resource: if resource:
self.addstr(y, 2, ' [+]' if contact._folded else ' [-]') self.addstr(y, 2, ' [+]' if contact._folded else ' [-]')
...@@ -1283,6 +1283,8 @@ class RosterWin(Win): ...@@ -1283,6 +1283,8 @@ class RosterWin(Win):
self.addstr(display_name, curses.color_pair(14)) self.addstr(display_name, curses.color_pair(14))
else: else:
self.addstr(display_name) self.addstr(display_name)
if contact.get_ask():
self.addstr('?', curses.color_pair(1))
def draw_resource_line(self, y, resource, colored): def draw_resource_line(self, y, resource, colored):
""" """
...@@ -1305,17 +1307,24 @@ class ContactInfoWin(Win): ...@@ -1305,17 +1307,24 @@ class ContactInfoWin(Win):
def resize(self, height, width, y, x, stdscr): def resize(self, height, width, y, x, stdscr):
self._resize(height, width, y, x, stdscr) self._resize(height, width, y, x, stdscr)
def draw_contact_info(self, resource, jid=None): def draw_contact_info(self, contact):
""" """
draw the contact information draw the contact information
""" """
jid = jid or resource.get_jid().full if contact:
jid = contact.get_bare_jid()
else:
jid = jid or resource.get_jid().full
resource = contact.get_highest_priority_resource()
if resource: if resource:
presence = resource.get_presence() presence = resource.get_presence()
else: else:
presence = 'unavailable' presence = 'unavailable'
self.addstr(0, 0, '%s (%s)'%(jid, presence,), curses.color_pair(theme.COLOR_INFORMATION_BAR)) self.addstr(0, 0, '%s (%s)'%(jid, presence,), curses.color_pair(theme.COLOR_INFORMATION_BAR))
self.finish_line(theme.COLOR_INFORMATION_BAR) self.finish_line(theme.COLOR_INFORMATION_BAR)
self.addstr(1, 0, 'Subscription: %s' % (contact.get_subscription(),))
if contact.get_ask():
self.addstr(' Ask: %s' % (contact.get_ask(),), curses.color_pair(1))
def draw_group_info(self, group): def draw_group_info(self, group):
""" """
...@@ -1330,10 +1339,9 @@ class ContactInfoWin(Win): ...@@ -1330,10 +1339,9 @@ class ContactInfoWin(Win):
if isinstance(selected_row, RosterGroup): if isinstance(selected_row, RosterGroup):
self.draw_group_info(selected_row) self.draw_group_info(selected_row)
elif isinstance(selected_row, Contact): elif isinstance(selected_row, Contact):
self.draw_contact_info(selected_row.get_highest_priority_resource(),
selected_row.get_bare_jid())
elif isinstance(selected_row, Resource):
self.draw_contact_info(selected_row) self.draw_contact_info(selected_row)
# elif isinstance(selected_row, Resource):
# self.draw_contact_info(None, selected_row)
self._refresh() self._refresh()
class ListWin(Win): class ListWin(Win):
......
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