From 48871f96ccc98b37fc75e94880cd29a93bcb0a3b Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 9 Sep 2016 23:54:33 +0200 Subject: [PATCH] quick frontend (chat): recreateArgs implementation --- frontends/src/quick_frontend/quick_chat.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontends/src/quick_frontend/quick_chat.py b/frontends/src/quick_frontend/quick_chat.py index 08558dc8..dc28227c 100644 --- a/frontends/src/quick_frontend/quick_chat.py +++ b/frontends/src/quick_frontend/quick_chat.py @@ -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