# HG changeset patch # User souliane # Date 1413553786 -7200 # Node ID b6dbac8ee4854fb5f825706fd8671cc53cc96da1 # Parent ff58a49a7022958067caf19cdd27d4884fb21dd0 plugin XEP-0045: handle MUC presence diff -r ff58a49a7022 -r b6dbac8ee485 src/plugins/plugin_xep_0045.py --- a/src/plugins/plugin_xep_0045.py Thu Oct 16 17:02:44 2014 +0200 +++ b/src/plugins/plugin_xep_0045.py Fri Oct 17 15:49:46 2014 +0200 @@ -28,6 +28,7 @@ from sat.memory import memory import uuid +import copy from wokkel import muc from sat.tools import xml_tools @@ -85,6 +86,8 @@ except KeyError: log.info(_("Text commands not available")) + host.trigger.add("presence_available", self.presenceTrigger) + def profileConnected(self, profile): def assign_service(service): client = self.host.getClient(profile) @@ -639,6 +642,15 @@ if user.show: whois_msg.append(_("Show: %s") % user.show) + def presenceTrigger(self, presence_elt, client): + # XXX: shouldn't it be done by the server ?!! + muc_client = self.clients[client.profile] + for room_jid_s, room in muc_client.joined_rooms.items(): + elt = copy.deepcopy(presence_elt) + elt['to'] = room_jid_s + '/' + room.nick + client.presence.send(elt) + return True + class SatMUCClient (muc.MUCClient): #implements(iwokkel.IDisco) @@ -712,8 +724,7 @@ self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile) def userUpdatedStatus(self, room, user, show, status): - print("FIXME: MUC status not managed yet") - #FIXME: + self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile) def receivedSubject(self, room, user, subject): log.debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})