comparison frontends/src/quick_frontend/quick_chat.py @ 507:f98bef71a918

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
author Goffi <goffi@goffi.org>
date Fri, 28 Sep 2012 00:26:24 +0200
parents e9634d2e7b38
children 886754295efe
comparison
equal deleted inserted replaced
506:2e43c74815ad 507:f98bef71a918
48 if self.type != "group": 48 if self.type != "group":
49 error (_("[INTERNAL] trying to set presents nicks for a non group chat window")) 49 error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
50 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here 50 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
51 self.occupants.update(nicks) 51 self.occupants.update(nicks)
52 52
53 def replaceUser(self, nick): 53 def replaceUser(self, nick, show_info=True):
54 """Add user if it is not in the group list""" 54 """Add user if it is not in the group list"""
55 debug (_("Replacing user %s") % nick) 55 debug (_("Replacing user %s") % nick)
56 if self.type != "group": 56 if self.type != "group":
57 error (_("[INTERNAL] trying to replace user for a non group chat window")) 57 error (_("[INTERNAL] trying to replace user for a non group chat window"))
58 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here 58 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
59 len_before = len(self.occupants) 59 len_before = len(self.occupants)
60 self.occupants.add(nick) 60 self.occupants.add(nick)
61 if len_before != len(self.occupants): 61 if len_before != len(self.occupants) and show_info:
62 self.printInfo("=> %s has joined the room" % nick) 62 self.printInfo("=> %s has joined the room" % nick)
63 63
64 def removeUser(self, nick, show_info=True):
65 """Remove a user from the group list"""
66 debug(_("Removing user %s") % nick)
67 if self.type != "group":
68 error (_("[INTERNAL] trying to remove user for a non group chat window"))
69 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
70 self.occupants.remove(nick)
71 if show_info:
72 self.printInfo("<= %s has left the room" % nick)
73
64 def setUserNick(self, nick): 74 def setUserNick(self, nick):
65 """Set the nick of the user, usefull for e.g. change the color of the user""" 75 """Set the nick of the user, usefull for e.g. change the color of the user"""
66 self.nick = nick 76 self.nick = nick
67 77
68 def getUserNick(self): 78 def getUserNick(self):
69 return unicode(self.nick) 79 return unicode(self.nick)
70 80
71 def removeUser(self, nick): 81 def changeUserNick(self, old_nick, new_nick):
72 """Remove a user from the group list""" 82 """Change nick of a user in group list"""
73 debug(_("Removing user %s") % nick) 83 debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
74 if self.type != "group": 84 if self.type != "group":
75 error (_("[INTERNAL] trying to remove user for a non group chat window")) 85 error (_("[INTERNAL] trying to change user nick for a non group chat window"))
76 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here 86 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
77 self.occupants.remove(nick) 87 self.removeUser(old_nick, show_info=False)
78 self.printInfo("<= %s has left the room" % nick) 88 self.replaceUser(new_nick, show_info=False)
89 self.printInfo("%s is now known as %s" % (old_nick, new_nick))
79 90
80 def setSubject(self, subject): 91 def setSubject(self, subject):
81 """Set title for a group chat""" 92 """Set title for a group chat"""
82 debug(_("Setting subject to %s") % subject) 93 debug(_("Setting subject to %s") % subject)
83 if self.type != "group": 94 if self.type != "group":