quick frontend, primitivus (chat, contact_list): fixed MUC private messages handling:
- occupants can be clicked again
- QuickChat.Occupant now keep room jid and real jid if available
- history messages are filtered correctly when requesting history for MUC room or private conversation
This commit is contained in:
parent
60c8f2fc3d
commit
82a12186ea
2 changed files with 38 additions and 17 deletions
|
|
@ -29,9 +29,9 @@ from sat_frontends.primitivus import game_tarot
|
|||
from sat_frontends.primitivus.constants import Const as C
|
||||
from sat_frontends.primitivus.keys import action_key_map as a_key
|
||||
from sat_frontends.primitivus.widget import PrimitivusWidget
|
||||
from sat_frontends.primitivus.contact_list import ContactList
|
||||
import time
|
||||
import locale
|
||||
from sat_frontends.tools import jid
|
||||
from functools import total_ordering
|
||||
import bisect
|
||||
|
||||
|
|
@ -141,7 +141,12 @@ class OccupantWidget(urwid.WidgetWrap):
|
|||
self.occupant_data = occupant_data
|
||||
occupant_data.widgets.add(self)
|
||||
markup = self._generateMarkup()
|
||||
super(OccupantWidget, self).__init__(urwid.Text(markup))
|
||||
text = sat_widgets.ClickableText(markup)
|
||||
urwid.connect_signal(text,
|
||||
'click',
|
||||
self.occupant_data.parent._occupantsClicked,
|
||||
user_args=[self.occupant_data])
|
||||
super(OccupantWidget, self).__init__(text)
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
|
|
@ -259,8 +264,6 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
|
|||
if type_ == C.CHAT_GROUP:
|
||||
if len(self.chat_colums.contents) == 1:
|
||||
self.occupants_widget = OccupantsWidget(self)
|
||||
# FIXME
|
||||
# , option_type=sat_widgets.ClickableText, on_click=self._occupantsClicked)
|
||||
self.occupants_panel = sat_widgets.VerticalSeparator(self.occupants_widget)
|
||||
self._appendOccupantsPanel()
|
||||
self.host.addListener('presence', self.presenceListener, [profiles])
|
||||
|
|
@ -473,21 +476,16 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
|
|||
if occupant is not None:
|
||||
self.occupants_widget.removeUser(occupant)
|
||||
|
||||
def _occupantsClicked(self, list_wid, clicked_wid):
|
||||
# FIXME: not called anymore after refactoring
|
||||
def _occupantsClicked(self, occupant, clicked_wid):
|
||||
assert self.type == C.CHAT_GROUP
|
||||
nick = clicked_wid.getValue().value
|
||||
if nick == self.nick:
|
||||
# We ignore clicks on our own nick
|
||||
return
|
||||
contact_list = self.host.contact_lists[self.profile]
|
||||
full_jid = jid.JID("%s/%s" % (self.target.bare, nick))
|
||||
|
||||
# we have a click on a nick, we need to create the widget if it doesn't exists
|
||||
self.getOrCreatePrivateWidget(full_jid)
|
||||
self.getOrCreatePrivateWidget(occupant.jid)
|
||||
|
||||
# now we select the new window
|
||||
contact_list.setFocus(full_jid, True)
|
||||
for contact_list in self.host.widgets.getWidgets(ContactList, profiles=(self.profile,)):
|
||||
contact_list.setFocus(occupant.jid, True)
|
||||
|
||||
def _appendOccupantsPanel(self):
|
||||
self.chat_colums.contents.append((self.occupants_panel, ('weight', 2, False)))
|
||||
|
|
|
|||
|
|
@ -120,14 +120,22 @@ class Occupant(object):
|
|||
self.parent = parent
|
||||
self.profile = profile
|
||||
self.nick = data['nick']
|
||||
self.entity = data.get('entity')
|
||||
if not self.entity:
|
||||
self.entity = jid.JID(u"{}/{}".format(parent.target.bare, self.nick)),
|
||||
self._entity = data.get('entity')
|
||||
self.affiliation = data['affiliation']
|
||||
self.role = data['role']
|
||||
self.widgets = set() # widgets linked to this occupant
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
def jid(self):
|
||||
"""jid in the room"""
|
||||
return jid.JID(u"{}/{}".format(self.parent.target.bare, self.nick))
|
||||
|
||||
@property
|
||||
def real_jid(self):
|
||||
"""real jid if known else None"""
|
||||
return self._entity
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
return self.parent.host
|
||||
|
|
@ -321,7 +329,22 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
log_msg += _(u" ({} messages)".format(size))
|
||||
log.debug(log_msg)
|
||||
|
||||
target = self.target.bare
|
||||
if self.type == C.CHAT_ONE2ONE:
|
||||
special = self.host.contact_lists[self.profile].getCache(self.target, C.CONTACT_SPECIAL)
|
||||
if special == C.CONTACT_SPECIAL_GROUP:
|
||||
# we have a private conversation
|
||||
# so we need full jid for the history
|
||||
# (else we would get history from group itself)
|
||||
# and to filter out groupchat message
|
||||
target = self.target
|
||||
filters['not_types'] = C.MESS_TYPE_GROUPCHAT
|
||||
else:
|
||||
target = self.target.bare
|
||||
else:
|
||||
# groupchat
|
||||
target = self.target.bare
|
||||
# FIXME: info not handled correctly
|
||||
filters['types'] = C.MESS_TYPE_GROUPCHAT
|
||||
|
||||
def _historyGetCb(history):
|
||||
# day_format = "%A, %d %b %Y" # to display the day change
|
||||
|
|
|
|||
Loading…
Reference in a new issue