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
This commit is contained in:
parent
a28bb7be8f
commit
04515e5013
3 changed files with 296 additions and 309 deletions
|
|
@ -30,6 +30,7 @@ from sat_frontends.primitivus.constants import Const as C
|
|||
from sat_frontends.primitivus.keys import action_key_map as a_key
|
||||
from sat_frontends.primitivus.widget import PrimitivusWidget
|
||||
import time
|
||||
import locale
|
||||
from sat_frontends.tools import jid
|
||||
from functools import total_ordering
|
||||
import bisect
|
||||
|
|
@ -117,8 +118,8 @@ class MessageWidget(urwid.WidgetWrap):
|
|||
# timestamp
|
||||
if self.parent.show_timestamp:
|
||||
# if the message was sent before today, we print the full date
|
||||
time_format = "%c" if self.timestamp < self.parent.day_change else "%H:%M"
|
||||
markup.append(('date', "[{}]".format(time.strftime(time_format, self.timestamp).decode('utf-8'))))
|
||||
time_format = u"%c" if self.timestamp < self.parent.day_change else u"%H:%M"
|
||||
markup.append(('date', u"[{}]".format(time.strftime(time_format, self.timestamp).decode(locale.getlocale()[1]))))
|
||||
|
||||
# nickname
|
||||
if self.parent.show_short_nick:
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
|
||||
def onJoinRoomRequest(self, menu):
|
||||
"""User wants to join a MUC room"""
|
||||
pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt=self.bridge.getDefaultMUC(), ok_cb=self.onJoinRoom)
|
||||
pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt=self.bridge.mucGetDefaultService(), ok_cb=self.onJoinRoom)
|
||||
pop_up_widget.setCallback('cancel', lambda dummy: self.removePopUp(pop_up_widget))
|
||||
self.showPopUp(pop_up_widget)
|
||||
|
||||
|
|
|
|||
|
|
@ -116,12 +116,12 @@ class ProfileManager(object):
|
|||
for sub in waiting_sub:
|
||||
self.host.subscribeHandler(waiting_sub[sub], sub, self.profile)
|
||||
|
||||
self.bridge.getRoomsJoined(self.profile, callback=self._plug_profile_gotRoomsJoined)
|
||||
self.bridge.mucGetRoomsJoined(self.profile, callback=self._plug_profile_gotRoomsJoined)
|
||||
|
||||
def _plug_profile_gotRoomsJoined(self, rooms_args):
|
||||
#Now we open the MUC window where we already are:
|
||||
for room_args in rooms_args:
|
||||
self.host.roomJoinedHandler(*room_args, profile=self.profile)
|
||||
self.host.mucRoomJoinedHandler(*room_args, profile=self.profile)
|
||||
#Presence must be requested after rooms are filled
|
||||
self.host.bridge.getPresenceStatuses(self.profile, callback=self._plug_profile_gotPresences)
|
||||
|
||||
|
|
@ -254,10 +254,10 @@ class QuickApp(object):
|
|||
self.registerSignal("progressFinished")
|
||||
self.registerSignal("progressError")
|
||||
self.registerSignal("actionResultExt", self.actionResultHandler)
|
||||
self.registerSignal("roomJoined", iface="plugin")
|
||||
self.registerSignal("roomLeft", iface="plugin")
|
||||
self.registerSignal("roomUserChangedNick", iface="plugin")
|
||||
self.registerSignal("roomNewSubject", iface="plugin")
|
||||
self.registerSignal("mucRoomJoined", iface="plugin")
|
||||
self.registerSignal("mucRoomLeft", iface="plugin")
|
||||
self.registerSignal("mucRoomUserChangedNick", iface="plugin")
|
||||
self.registerSignal("mucRoomNewSubject", iface="plugin")
|
||||
self.registerSignal("chatStateReceived", iface="plugin")
|
||||
self.registerSignal("psEvent", iface="plugin")
|
||||
|
||||
|
|
@ -548,7 +548,7 @@ class QuickApp(object):
|
|||
|
||||
self.callListeners('presence', entity, show, priority, statuses, profile=profile)
|
||||
|
||||
def roomJoinedHandler(self, room_jid_s, occupants, user_nick, subject, profile):
|
||||
def mucRoomJoinedHandler(self, room_jid_s, occupants, user_nick, subject, profile):
|
||||
"""Called when a MUC room is joined"""
|
||||
log.debug(u"Room [{room_jid}] joined by {profile}, users presents:{users}".format(room_jid=room_jid_s, profile=profile, users=occupants.keys()))
|
||||
room_jid = jid.JID(room_jid_s)
|
||||
|
|
@ -557,7 +557,7 @@ class QuickApp(object):
|
|||
self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP)
|
||||
# chat_widget.update()
|
||||
|
||||
def roomLeftHandler(self, room_jid_s, profile):
|
||||
def mucRoomLeftHandler(self, room_jid_s, profile):
|
||||
"""Called when a MUC room is left"""
|
||||
log.debug(u"Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile})
|
||||
room_jid = jid.JID(room_jid_s)
|
||||
|
|
@ -566,14 +566,14 @@ class QuickApp(object):
|
|||
self.widgets.deleteWidget(chat_widget)
|
||||
self.contact_lists[profile].removeContact(room_jid)
|
||||
|
||||
def roomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile):
|
||||
def mucRoomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile):
|
||||
"""Called when an user joined a MUC room"""
|
||||
room_jid = jid.JID(room_jid_s)
|
||||
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
|
||||
chat_widget.changeUserNick(old_nick, new_nick)
|
||||
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})
|
||||
|
||||
def roomNewSubjectHandler(self, room_jid_s, subject, profile):
|
||||
def mucRoomNewSubjectHandler(self, room_jid_s, subject, profile):
|
||||
"""Called when subject of MUC room change"""
|
||||
room_jid = jid.JID(room_jid_s)
|
||||
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
|
||||
|
|
|
|||
Loading…
Reference in a new issue