Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-06-18 18:14:59 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-06-18 18:14:59 (GMT)
commit9d7a7f80504f3154cbd61d3e8c98bbebcbce4eb4 (patch)
tree1f3b7f75f46fa14d444cbcb913bcbd903002b9c9 /sugar
parent51ea9eedba1891abdc004433bfe29a4ae3cc50b1 (diff)
Fix the confusion when running multiple instances on the
same box by passing the nick name in the message.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/chat/Chat.py14
-rw-r--r--sugar/chat/GroupChat.py5
2 files changed, 16 insertions, 3 deletions
diff --git a/sugar/chat/Chat.py b/sugar/chat/Chat.py
index b43f103..d33d27f 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 f143226..5ab0645 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))