Fix the confusion when running multiple instances on the
same box by passing the nick name in the message.
This commit is contained in:
parent
51ea9eedba
commit
9d7a7f8050
@ -184,6 +184,11 @@ class Chat(gtk.VBox):
|
|||||||
if not buddy:
|
if not buddy:
|
||||||
return
|
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)
|
chunk = self._get_first_richtext_chunk(msg)
|
||||||
if chunk:
|
if chunk:
|
||||||
self._insert_rich_message(buddy, 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."""
|
"""Send a chat message and insert it into the local buffer."""
|
||||||
if len(text) <= 0:
|
if len(text) <= 0:
|
||||||
return
|
return
|
||||||
self._stream_writer.write(text)
|
self._stream_writer.write(self.serialize_message(text))
|
||||||
owner = PresenceService.get_instance().get_owner()
|
owner = PresenceService.get_instance().get_owner()
|
||||||
self._insert_rich_message(owner, text)
|
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)
|
||||||
|
@ -39,8 +39,9 @@ class GroupChat(Chat):
|
|||||||
|
|
||||||
def _group_recv_message(self, address, msg):
|
def _group_recv_message(self, address, msg):
|
||||||
pservice = PresenceService.get_instance()
|
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:
|
if buddy:
|
||||||
self.recv_message(buddy, msg)
|
self.recv_message(buddy, msg)
|
||||||
else:
|
else:
|
||||||
logging.error('Cannot map %s to a buddy.' % (address))
|
logging.error('The buddy %s is not present.' % (nick))
|
||||||
|
Loading…
Reference in New Issue
Block a user