comparison frontends/src/quick_frontend/quick_chat.py @ 688:f7878ad3c846

tools: renamed tools.jid.JID attribute "short" to "bare"
author souliane <souliane@mailoo.org>
date Tue, 29 Oct 2013 16:26:55 +0100
parents 0b9bd47dffcd
children 6246eb6d64a0
comparison
equal deleted inserted replaced
687:af0d08a84cc6 688:f7878ad3c846
108 error (_("Can't get history")) 108 error (_("Can't get history"))
109 109
110 if self.target.startswith(const_PRIVATE_PREFIX): 110 if self.target.startswith(const_PRIVATE_PREFIX):
111 target = unescapePrivate(self.target) 111 target = unescapePrivate(self.target)
112 else: 112 else:
113 target = self.target.short 113 target = self.target.bare
114 114
115 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, target, 20, profile=profile, callback=onHistory, errback=onHistoryError) 115 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].bare, target, 20, profile=profile, callback=onHistory, errback=onHistoryError)
116 116
117 def _get_nick(self, jid): 117 def _get_nick(self, jid):
118 """Return nick of this jid when possible""" 118 """Return nick of this jid when possible"""
119 if self.target.startswith(const_PRIVATE_PREFIX): 119 if self.target.startswith(const_PRIVATE_PREFIX):
120 unescaped = unescapePrivate(self.target) 120 unescaped = unescapePrivate(self.target)
121 if jid.startswith(const_PRIVATE_PREFIX) or unescaped.short == jid.short: 121 if jid.startswith(const_PRIVATE_PREFIX) or unescaped.bare == jid.bare:
122 return unescaped.resource 122 return unescaped.resource
123 return jid.resource if self.type == "group" else (self.host.contact_list.getCache(jid,'nick') or self.host.contact_list.getCache(jid,'name') or jid.node) 123 return jid.resource if self.type == "group" else (self.host.contact_list.getCache(jid,'nick') or self.host.contact_list.getCache(jid,'name') or jid.node)
124 124
125 def printMessage(self, from_jid, msg, profile, timestamp = ''): 125 def printMessage(self, from_jid, msg, profile, timestamp = ''):
126 """Print message in chat window. Must be implemented by child class""" 126 """Print message in chat window. Must be implemented by child class"""
127 jid=JID(from_jid) 127 jid=JID(from_jid)
128 nick = self._get_nick(jid) 128 nick = self._get_nick(jid)
129 mymess = (jid.resource == self.nick) if self.type == "group" else (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user 129 mymess = (jid.resource == self.nick) if self.type == "group" else (jid.bare == self.host.profiles[profile]['whoami'].bare) #mymess = True if message comes from local user
130 if msg.startswith('/me '): 130 if msg.startswith('/me '):
131 self.printInfo('* %s %s' % (nick, msg[4:]),type='me', timestamp=timestamp) 131 self.printInfo('* %s %s' % (nick, msg[4:]),type='me', timestamp=timestamp)
132 return 132 return
133 return jid, nick, mymess 133 return jid, nick, mymess
134 134