QuickFrontend, Primitivus, Wix: special entities management:
- MUC rooms are special entities - Primitivus: special entities are shown at the top of the contacts list above a divider, presence updates are temporary ignored for them
This commit is contained in:
parent
b44412ec0d
commit
80faa0976c
4 changed files with 61 additions and 3 deletions
|
|
@ -32,6 +32,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
self.host = host
|
||||
self.selected = None
|
||||
self.groups={}
|
||||
self.special={}
|
||||
self.alert_jid=set()
|
||||
self.show_status = False
|
||||
self.show_disconnected = False
|
||||
|
|
@ -76,9 +77,12 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
"""give focus to the first group or contact with the given name"""
|
||||
idx = 0
|
||||
for widget in self.frame.body.body:
|
||||
if widget.getValue() == name:
|
||||
self.frame.body.set_focus(idx)
|
||||
return
|
||||
try:
|
||||
if widget.getValue() == name:
|
||||
self.frame.body.set_focus(idx)
|
||||
return
|
||||
except AttributeError:
|
||||
pass
|
||||
idx+=1
|
||||
|
||||
def putAlert(self, jid):
|
||||
|
|
@ -141,9 +145,32 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
content.append(widget)
|
||||
urwid.connect_signal(widget, 'change', self.__contactClicked)
|
||||
|
||||
def __buildSpecials(self, content):
|
||||
"""Build the special entities"""
|
||||
specials = self.special.keys()
|
||||
specials.sort()
|
||||
for special in specials:
|
||||
jid=JID(special)
|
||||
name = self.getCache(jid, 'name')
|
||||
nick = self.getCache(jid, 'nick')
|
||||
special_disp = ('alert' if special in self.alert_jid else 'default', nick or name or jid.node or jid.short)
|
||||
display = [ " " , special_disp]
|
||||
header = '(*) ' if special in self.alert_jid else ''
|
||||
widget = sat_widgets.SelectableText(display,
|
||||
selected = special==self.selected,
|
||||
header=header)
|
||||
widget.data = special
|
||||
content.append(widget)
|
||||
urwid.connect_signal(widget, 'change', self.__contactClicked)
|
||||
|
||||
def __buildList(self):
|
||||
"""Build the main contact list widget"""
|
||||
content = urwid.SimpleListWalker([])
|
||||
|
||||
self.__buildSpecials(content)
|
||||
if self.special:
|
||||
content.append(urwid.Divider('='))
|
||||
|
||||
group_keys = self.groups.keys()
|
||||
group_keys.sort(key = lambda x: x.lower() if x else x)
|
||||
for key in group_keys:
|
||||
|
|
@ -178,6 +205,8 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
|
||||
def replace(self, jid, groups=None, attributes=None):
|
||||
"""add a contact to the list if doesn't exist, else update it"""
|
||||
if jid.short in self.special:
|
||||
return
|
||||
if not groups:
|
||||
groups = [None]
|
||||
if not attributes:
|
||||
|
|
@ -216,3 +245,21 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
"""add a contact to the list"""
|
||||
self.replace(jid,param_groups)
|
||||
|
||||
def setSpecial(self, special_jid, special_type):
|
||||
"""Set entity as a special
|
||||
@param jid: jid of the entity
|
||||
@param _type: special type (e.g.: "MUC")
|
||||
"""
|
||||
self.special[special_jid.short] = special_type
|
||||
if None in self.groups:
|
||||
folded,group_jids = self.groups[None]
|
||||
for group_jid in group_jids:
|
||||
if JID(group_jid).short == special_jid.short:
|
||||
group_jids.remove(group_jid)
|
||||
break
|
||||
self.update()
|
||||
|
||||
def updatePresence(self, jid, show, priority, statuses):
|
||||
#XXX: for the moment, we ignore presence updates for special entities
|
||||
if jid.short not in self.special:
|
||||
QuickContactList.updatePresence(self, jid, show, priority, statuses)
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ class QuickApp():
|
|||
self.chat_wins[room_jid].setType("group")
|
||||
self.chat_wins[room_jid].id = room_jid
|
||||
self.chat_wins[room_jid].setPresents(list(set([user_nick]+room_nicks)))
|
||||
self.contact_list.setSpecial(JID(room_jid), "MUC")
|
||||
|
||||
|
||||
def roomUserJoined(self, room_jid, user_nick, user_data, profile):
|
||||
|
|
|
|||
|
|
@ -70,6 +70,13 @@ class QuickContactList():
|
|||
"""add a contact to the list"""
|
||||
raise NotImplementedError
|
||||
|
||||
def setSpecial(self, jid, _type):
|
||||
"""Set entity as a special
|
||||
@param jid: jid of the entity
|
||||
@param _type: special type (e.g.: "MUC")
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def updatePresence(self, jid, show, priority, statuses):
|
||||
"""Update entity's presence status
|
||||
@param jid: entity to update's jid
|
||||
|
|
@ -80,3 +87,4 @@ class QuickContactList():
|
|||
self.setCache(jid, 'prority', priority)
|
||||
self.setCache(jid, 'statuses', statuses)
|
||||
self.update_jid(jid)
|
||||
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
|||
if _present:
|
||||
self.Insert(_present, gp_idx+1, contact)
|
||||
|
||||
def setSpecial(self, special_jid, special_type):
|
||||
pass
|
||||
|
||||
|
||||
def remove(self, contact):
|
||||
|
|
|
|||
Loading…
Reference in a new issue