From 9a1743f695b95a71c974ad8c7af178ab0dc3d130 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Sun, 13 Jun 2010 13:51:02 +0000 Subject: Private messages! fixed #1077 --- src/connection.py | 12 +++++- src/gui.py | 118 ++++++++++++++++++++++++++++++++++++++++++++------- src/handler.py | 4 ++ src/multiuserchat.py | 7 +++ src/room.py | 8 +++- src/window.py | 39 ++++++++++++++--- 6 files changed, 162 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/connection.py b/src/connection.py index 5c94b3fa..e20aaab5 100644 --- a/src/connection.py +++ b/src/connection.py @@ -173,7 +173,10 @@ class Connection(threading.Thread): if message.getType() == 'error': self.error_message(message) return - self.handler.emit('room-message', stanza=message) + if message.getType() == 'groupchat': + self.handler.emit('room-message', stanza=message) + else: + self.handler.emit('private-message', stanza=message) raise xmpp.protocol.NodeProcessed def process(self, timeout=10): @@ -213,3 +216,10 @@ def jid_get_domain(jid): if isinstance(jid, basestring): jid = xmpp.JID(jid) return jid.getDomain() + +def is_jid_the_same(a, b): + if isinstance(a, basestring): + a = xmpp.JID(a) + if isinstance(b, basestring): + b = xmpp.JID(b) + return a.bareMatch(b) diff --git a/src/gui.py b/src/gui.py index 685bcb97..b127abb5 100644 --- a/src/gui.py +++ b/src/gui.py @@ -40,6 +40,8 @@ from user import User from room import Room from message import Message +from connection import is_jid_the_same + from common import debug def doupdate(): debug("doupdate") @@ -83,6 +85,8 @@ class Gui(object): 'set': (self.command_set, _("Usage: /set