diff --git a/sugar/chat/Chat.py b/sugar/chat/Chat.py index b43f103a..d33d27f1 100644 --- a/sugar/chat/Chat.py +++ b/sugar/chat/Chat.py @@ -184,6 +184,11 @@ class Chat(gtk.VBox): if not buddy: return + # FIXME a better way to compare buddies? + owner = PresenceService.get_instance().get_owner() + if buddy.get_nick_name() == owner.get_nick_name(): + return + chunk = self._get_first_richtext_chunk(msg) if chunk: self._insert_rich_message(buddy, chunk) @@ -205,6 +210,13 @@ class Chat(gtk.VBox): """Send a chat message and insert it into the local buffer.""" if len(text) <= 0: return - self._stream_writer.write(text) + self._stream_writer.write(self.serialize_message(text)) owner = PresenceService.get_instance().get_owner() self._insert_rich_message(owner, text) + + def serialize_message(self, message): + owner = PresenceService.get_instance().get_owner() + return owner.get_nick_name() + '||' + message + + def deserialize_message(self, message): + return message.split('||', 1) diff --git a/sugar/chat/GroupChat.py b/sugar/chat/GroupChat.py index f1432268..5ab06454 100644 --- a/sugar/chat/GroupChat.py +++ b/sugar/chat/GroupChat.py @@ -39,8 +39,9 @@ class GroupChat(Chat): def _group_recv_message(self, address, msg): pservice = PresenceService.get_instance() - buddy = pservice.get_buddy_by_address(address) + [nick, msg] = self.deserialize_message(msg) + buddy = pservice.get_buddy_by_nick_name(nick) if buddy: self.recv_message(buddy, msg) else: - logging.error('Cannot map %s to a buddy.' % (address)) + logging.error('The buddy %s is not present.' % (nick))