comparison frontends/src/primitivus/chat.py @ 1378:3dae6964c071

quick_frontends, primitivus: move the chat states logic to quick_frontend
author souliane <souliane@mailoo.org>
date Fri, 20 Mar 2015 16:28:19 +0100
parents 017270e6eea4
children b01efa1c0f5e
comparison
equal deleted inserted replaced
1377:017270e6eea4 1378:3dae6964c071
148 elif self.type == C.CHAT_ONE2ONE: 148 elif self.type == C.CHAT_ONE2ONE:
149 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target}) 149 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target})
150 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) 150 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
151 return menu 151 return menu
152 152
153 def updateChatState(self, from_jid, state): 153 def setOccupantStates(self, occupant_jid, states):
154 if self.type == C.CHAT_GROUP: 154 """Set a MUC occupant's states.
155 if from_jid == C.ENTITY_ALL: 155
156 occupants = self.occupants 156 @param occupant_jid (jid.JID): occupant to update
157 else: 157 @param states (dict{unicode: unicode}): new states
158 nick = from_jid.resource 158 """
159 if not nick: 159 options = self.present_wid.getAllValues()
160 log.debug("no nick found for chatstate") 160 for index in xrange(0, len(options)):
161 return 161 nick = options[index].value
162 occupants = [nick] 162 if nick == occupant_jid.resource:
163 options = self.present_wid.getAllValues() 163 options[index] = (nick, "%s %s" % (u''.join(states.values()), nick))
164 for index in xrange(0, len(options)): 164 self.present_wid.changeValues(options)
165 nick = options[index].value 165 break
166 if nick in occupants: 166 self.host.redraw()
167 options[index] = (nick, '%s %s' % (C.MUC_USER_STATES[state], nick)) 167
168 self.present_wid.changeValues(options) 168 def setContactStates(self, contact_jid, states):
169 self.host.redraw() 169 """Set a one2one contact's states.
170 else: 170
171 self.title_dynamic = '({})'.format(state) 171 @param contact_jid (jid.JID): contact
172 @param states (dict{unicode: unicode}): new states
173 """
174 self.title_dynamic = ' '.join([u'({})'.format(state) for state in states.values()])
175 self.host.redraw()
172 176
173 def _presentClicked(self, list_wid, clicked_wid): 177 def _presentClicked(self, list_wid, clicked_wid):
174 assert self.type == C.CHAT_GROUP 178 assert self.type == C.CHAT_GROUP
175 nick = clicked_wid.getValue().value 179 nick = clicked_wid.getValue().value
176 if nick == self.getUserNick(): 180 if nick == self.getUserNick():