frontends, core, plugin XEP-0045: leave implementation + better nick change

- memory: individual entity cache can be deleted
	- plugin XEP-0045: nick change are now detected and userChangedNick signal is sent instead of joined/left
	- plugin XEP-0045: leave implementation
	- frontends: userChangedNick signal management
	- Primitivus: an alert is shown in notification bar in case of error in sendMessage
This commit is contained in:
Goffi 2012-09-28 00:26:24 +02:00
commit c520325941

View file

@ -50,7 +50,7 @@ class QuickChat():
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
self.occupants.update(nicks)
def replaceUser(self, nick):
def replaceUser(self, nick, show_info=True):
"""Add user if it is not in the group list"""
debug (_("Replacing user %s") % nick)
if self.type != "group":
@ -58,24 +58,35 @@ class QuickChat():
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
len_before = len(self.occupants)
self.occupants.add(nick)
if len_before != len(self.occupants):
if len_before != len(self.occupants) and show_info:
self.printInfo("=> %s has joined the room" % nick)
def setUserNick(self, nick):
"""Set the nick of the user, usefull for e.g. change the color of the user"""
self.nick = nick
def getUserNick(self):
return unicode(self.nick)
def removeUser(self, nick):
def removeUser(self, nick, show_info=True):
"""Remove a user from the group list"""
debug(_("Removing user %s") % nick)
if self.type != "group":
error (_("[INTERNAL] trying to remove user for a non group chat window"))
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
self.occupants.remove(nick)
self.printInfo("<= %s has left the room" % nick)
if show_info:
self.printInfo("<= %s has left the room" % nick)
def setUserNick(self, nick):
"""Set the nick of the user, usefull for e.g. change the color of the user"""
self.nick = nick
def getUserNick(self):
return unicode(self.nick)
def changeUserNick(self, old_nick, new_nick):
"""Change nick of a user in group list"""
debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
if self.type != "group":
error (_("[INTERNAL] trying to change user nick for a non group chat window"))
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
self.removeUser(old_nick, show_info=False)
self.replaceUser(new_nick, show_info=False)
self.printInfo("%s is now known as %s" % (old_nick, new_nick))
def setSubject(self, subject):
"""Set title for a group chat"""