comparison frontends/src/quick_frontend/quick_app.py @ 1970:200cd707a46d

plugin XEP-0045, quick_frontend + primitivus (chat): cleaning of XEP-0045 (first pass): - bridge methods/signals now all start with "muc" to follow new convention - internal method use client instead of profile to follow new convention - removed excetpions from plugin XEP-0045 in favor of core.exceptions, NotReady added - cleaned/simplified several part of the code. checkClient removed as it is not needed anymore - self.clients map removed, muc data are now stored directly in client - getRoomEntityNick and getRoomNicksOfUsers are removed as they don't look sane. /!\ This break all room game plugins for the moment - use of uuid4 instead of uuid1 for getUniqueName, as host ID and current time are used for uuid1
author Goffi <goffi@goffi.org>
date Mon, 27 Jun 2016 21:45:11 +0200
parents a2bc5089c2eb
children 02d21a589be2
comparison
equal deleted inserted replaced
1969:5fbe09b9b568 1970:200cd707a46d
114 114
115 def _plug_profile_gotWaitingSub(self, waiting_sub): 115 def _plug_profile_gotWaitingSub(self, waiting_sub):
116 for sub in waiting_sub: 116 for sub in waiting_sub:
117 self.host.subscribeHandler(waiting_sub[sub], sub, self.profile) 117 self.host.subscribeHandler(waiting_sub[sub], sub, self.profile)
118 118
119 self.bridge.getRoomsJoined(self.profile, callback=self._plug_profile_gotRoomsJoined) 119 self.bridge.mucGetRoomsJoined(self.profile, callback=self._plug_profile_gotRoomsJoined)
120 120
121 def _plug_profile_gotRoomsJoined(self, rooms_args): 121 def _plug_profile_gotRoomsJoined(self, rooms_args):
122 #Now we open the MUC window where we already are: 122 #Now we open the MUC window where we already are:
123 for room_args in rooms_args: 123 for room_args in rooms_args:
124 self.host.roomJoinedHandler(*room_args, profile=self.profile) 124 self.host.mucRoomJoinedHandler(*room_args, profile=self.profile)
125 #Presence must be requested after rooms are filled 125 #Presence must be requested after rooms are filled
126 self.host.bridge.getPresenceStatuses(self.profile, callback=self._plug_profile_gotPresences) 126 self.host.bridge.getPresenceStatuses(self.profile, callback=self._plug_profile_gotPresences)
127 127
128 def _plug_profile_gotPresences(self, presences): 128 def _plug_profile_gotPresences(self, presences):
129 def gotEntityData(data, contact): 129 def gotEntityData(data, contact):
252 self.registerSignal("actionResult") 252 self.registerSignal("actionResult")
253 self.registerSignal("progressStarted") 253 self.registerSignal("progressStarted")
254 self.registerSignal("progressFinished") 254 self.registerSignal("progressFinished")
255 self.registerSignal("progressError") 255 self.registerSignal("progressError")
256 self.registerSignal("actionResultExt", self.actionResultHandler) 256 self.registerSignal("actionResultExt", self.actionResultHandler)
257 self.registerSignal("roomJoined", iface="plugin") 257 self.registerSignal("mucRoomJoined", iface="plugin")
258 self.registerSignal("roomLeft", iface="plugin") 258 self.registerSignal("mucRoomLeft", iface="plugin")
259 self.registerSignal("roomUserChangedNick", iface="plugin") 259 self.registerSignal("mucRoomUserChangedNick", iface="plugin")
260 self.registerSignal("roomNewSubject", iface="plugin") 260 self.registerSignal("mucRoomNewSubject", iface="plugin")
261 self.registerSignal("chatStateReceived", iface="plugin") 261 self.registerSignal("chatStateReceived", iface="plugin")
262 self.registerSignal("psEvent", iface="plugin") 262 self.registerSignal("psEvent", iface="plugin")
263 263
264 # FIXME: do it dynamically 264 # FIXME: do it dynamically
265 quick_games.Tarot.registerSignals(self) 265 quick_games.Tarot.registerSignals(self)
546 self.setPresenceStatus(show, status, profile=profile) 546 self.setPresenceStatus(show, status, profile=profile)
547 return 547 return
548 548
549 self.callListeners('presence', entity, show, priority, statuses, profile=profile) 549 self.callListeners('presence', entity, show, priority, statuses, profile=profile)
550 550
551 def roomJoinedHandler(self, room_jid_s, occupants, user_nick, subject, profile): 551 def mucRoomJoinedHandler(self, room_jid_s, occupants, user_nick, subject, profile):
552 """Called when a MUC room is joined""" 552 """Called when a MUC room is joined"""
553 log.debug(u"Room [{room_jid}] joined by {profile}, users presents:{users}".format(room_jid=room_jid_s, profile=profile, users=occupants.keys())) 553 log.debug(u"Room [{room_jid}] joined by {profile}, users presents:{users}".format(room_jid=room_jid_s, profile=profile, users=occupants.keys()))
554 room_jid = jid.JID(room_jid_s) 554 room_jid = jid.JID(room_jid_s)
555 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, occupants=occupants, subject=subject, profile=profile) 555 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, occupants=occupants, subject=subject, profile=profile)
556 chat_widget.setUserNick(unicode(user_nick)) 556 chat_widget.setUserNick(unicode(user_nick))
557 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP) 557 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP)
558 # chat_widget.update() 558 # chat_widget.update()
559 559
560 def roomLeftHandler(self, room_jid_s, profile): 560 def mucRoomLeftHandler(self, room_jid_s, profile):
561 """Called when a MUC room is left""" 561 """Called when a MUC room is left"""
562 log.debug(u"Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile}) 562 log.debug(u"Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile})
563 room_jid = jid.JID(room_jid_s) 563 room_jid = jid.JID(room_jid_s)
564 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, room_jid, profile) 564 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, room_jid, profile)
565 if chat_widget: 565 if chat_widget:
566 self.widgets.deleteWidget(chat_widget) 566 self.widgets.deleteWidget(chat_widget)
567 self.contact_lists[profile].removeContact(room_jid) 567 self.contact_lists[profile].removeContact(room_jid)
568 568
569 def roomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile): 569 def mucRoomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile):
570 """Called when an user joined a MUC room""" 570 """Called when an user joined a MUC room"""
571 room_jid = jid.JID(room_jid_s) 571 room_jid = jid.JID(room_jid_s)
572 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile) 572 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
573 chat_widget.changeUserNick(old_nick, new_nick) 573 chat_widget.changeUserNick(old_nick, new_nick)
574 log.debug(u"user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid}) 574 log.debug(u"user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid})
575 575
576 def roomNewSubjectHandler(self, room_jid_s, subject, profile): 576 def mucRoomNewSubjectHandler(self, room_jid_s, subject, profile):
577 """Called when subject of MUC room change""" 577 """Called when subject of MUC room change"""
578 room_jid = jid.JID(room_jid_s) 578 room_jid = jid.JID(room_jid_s)
579 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile) 579 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
580 chat_widget.setSubject(subject) 580 chat_widget.setSubject(subject)
581 log.debug(u"new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject}) 581 log.debug(u"new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject})