comparison frontends/src/quick_frontend/quick_chat.py @ 510:886754295efe

quick frontend, primitivus, wix: MUC private messages management /!\ not fully finished, backend part is not done yet /!\ - as resources are discarded to manage chat windows lists, a pretty dirty hack is done to work around this: full jid is escaped using a prefix (it becomes invalid and resource is preserved). - new quick_utils module, with helper methods. escapePrivate and unescapePrivate implementations - MUC private messages are not managed in Wix yet
author Goffi <goffi@goffi.org>
date Thu, 11 Oct 2012 00:48:35 +0200
parents f98bef71a918
children 862c0d6ab974
comparison
equal deleted inserted replaced
509:64ff046dc201 510:886754295efe
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
23 from sat.tools.jid import JID 23 from sat.tools.jid import JID
24 24 from sat_frontends.quick_frontend.quick_utils import unescapePrivate
25 25
26 26
27 class QuickChat(): 27 class QuickChat():
28 28
29 def __init__(self, target, host, type='one2one'): 29 def __init__(self, target, host, type='one2one'):
108 108
109 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError) 109 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError)
110 110
111 def _get_nick(self, jid): 111 def _get_nick(self, jid):
112 """Return nick of this jid when possible""" 112 """Return nick of this jid when possible"""
113 if jid.startswith(const_PRIVATE_PREFIX):
114 return unescapePrivate(jid).resource
113 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) 115 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)
114 116
115 def printMessage(self, from_jid, msg, profile, timestamp): 117 def printMessage(self, from_jid, msg, profile, timestamp):
116 """Print message in chat window. Must be implemented by child class""" 118 """Print message in chat window. Must be implemented by child class"""
117 jid=JID(from_jid) 119 jid=JID(from_jid)