Mercurial > libervia-web
diff browser_side/richtext.py @ 280:1ccdc34cfb60
browser_side: changes related to the implementation of XEP-0033 (addressing)
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 04 Dec 2013 21:52:30 +0100 |
parents | aebb96bfa8d1 |
children | 36ce989c73a5 |
line wrap: on
line diff
--- a/browser_side/richtext.py Sat Nov 23 14:46:03 2013 +0100 +++ b/browser_side/richtext.py Wed Dec 04 21:52:30 2013 +0100 @@ -181,10 +181,7 @@ self.textarea.setText(data if data else "") def syncToUniBox(self, recipients=None, emptyText=False): - """Synchronize to unibox if a maximum of one recipient is set, - and it is not set to for optional recipient type. That means - synchronization is not done if more then one recipients are set - or if a recipient is set to an optional type (Cc, Bcc). + """Synchronize to unibox if a maximum of one recipient is set. @return True if the sync could be done, False otherwise""" if recipients is None: recipients = self.recipient.getContacts() @@ -196,7 +193,7 @@ if count == 0: continue allowed -= count - if allowed < 0 or composition.RECIPIENT_TYPES[key]["optional"]: + if allowed < 0: return False # TODO: change this if later more then one recipients are allowed target = recipients[key][0] @@ -237,25 +234,21 @@ def sendMessage(self): """Send the message.""" recipients = self.recipient.getContacts() - for key in recipients: - if len(recipients[key]) > 0 and composition.RECIPIENT_TYPES[key]["optional"]: - InfoDialog("Feature in development", - "Sending a message to Cc or Bcc is not implemented yet!", Width="400px").center() - return text = self.textarea.getText() + targets = [] + for addr in recipients: + for recipient in recipients[addr]: + if recipient.startswith("@"): + targets.append(("PUBLIC", None, addr) if recipient == "@@" else ("GROUP", recipient[1:], addr)) + else: + targets.append(("chat", recipient, addr)) # check that we actually have a message target and data - if text == "" or len(recipients["To"]) == 0: + if text == "" or len(targets) == 0: InfoDialog("Missing information", "Some information are missing and the message hasn't been sent.", Width="400px").center() return self.syncToUniBox(recipients, emptyText=True) - targets = [] - for recipient in recipients["To"]: - if recipient.startswith("@"): - targets.append(("PUBLIC", None) if recipient == "@@" else ("GROUP", recipient[1:])) - else: - targets.append(("chat", recipient)) - self.host.send(targets, text, rich=True) + self.host.send(targets, text, extra={'rich': text}) self.__close()