quick frontend (chat): recreateArgs implementation

This commit is contained in:
Goffi 2016-09-09 23:54:33 +02:00
commit 48871f96cc

View file

@ -181,6 +181,17 @@ class Occupant(object):
self.widgets = set() # widgets linked to this occupant
self._state = None
@property
def data(self):
"""reconstruct data dict from attributes"""
data = {}
data['nick'] = self.nick
if self._entity is not None:
data['entity'] = self._entity
data['affiliation'] = self.affiliation
data['role'] = self.role
return data
@property
def jid(self):
"""jid in the room"""
@ -273,6 +284,13 @@ class QuickChat(quick_widgets.QuickWidget):
if target.resource:
self.current_target = target # FIXME: tmp, must use resource priority throught contactList instead
def recreateArgs(self, args, kwargs):
"""copy important attribute for a new widget"""
kwargs['type_'] = self.type
if self.type == C.CHAT_GROUP:
kwargs['occupants'] = {o.nick: o.data for o in self.occupants.itervalues()}
kwargs['subject'] = self.subject
def onPrivateCreated(self, widget):
"""Method called when a new widget for private conversation (MUC) is created"""
raise NotImplementedError