comparison src/plugins/plugin_xep_0045.py @ 1466:2184d5f496b5

plugin XEP-0045: added disco announce
author Goffi <goffi@goffi.org>
date Tue, 18 Aug 2015 09:01:18 +0200
parents 176de79c8c39
children 55967cf161b1
comparison
equal deleted inserted replaced
1465:cbf38047ca60 1466:2184d5f496b5
28 from sat.memory import memory 28 from sat.memory import memory
29 29
30 import uuid 30 import uuid
31 import copy 31 import copy
32 32
33 from wokkel import muc 33 from wokkel import muc, disco, iwokkel
34 from sat.tools import xml_tools 34 from sat.tools import xml_tools
35
36 from zope.interface import implements
35 37
36 38
37 PLUGIN_INFO = { 39 PLUGIN_INFO = {
38 "name": "XEP 0045 Plugin", 40 "name": "XEP 0045 Plugin",
39 "import_name": "XEP-0045", 41 "import_name": "XEP-0045",
44 "main": "XEP_0045", 46 "main": "XEP_0045",
45 "handler": "yes", 47 "handler": "yes",
46 "description": _("""Implementation of Multi-User Chat""") 48 "description": _("""Implementation of Multi-User Chat""")
47 } 49 }
48 50
51 NS_MUC = 'http://jabber.org/protocol/muc'
49 AFFILIATIONS = ('owner', 'admin', 'member', 'none', 'outcast') 52 AFFILIATIONS = ('owner', 'admin', 'member', 'none', 'outcast')
50 53
51 CONFIG_SECTION = u'plugin muc' 54 CONFIG_SECTION = u'plugin muc'
52 55
53 default_conf = {"default_muc": u'sat@chat.jabberfr.org'} 56 default_conf = {"default_muc": u'sat@chat.jabberfr.org'}
661 client.presence.send(elt) 664 client.presence.send(elt)
662 return True 665 return True
663 666
664 667
665 class SatMUCClient (muc.MUCClient): 668 class SatMUCClient (muc.MUCClient):
666 # implements(iwokkel.IDisco) 669 implements(iwokkel.IDisco)
667 670
668 def __init__(self, plugin_parent): 671 def __init__(self, plugin_parent):
669 self.plugin_parent = plugin_parent 672 self.plugin_parent = plugin_parent
670 self.host = plugin_parent.host 673 self.host = plugin_parent.host
671 muc.MUCClient.__init__(self) 674 muc.MUCClient.__init__(self)
747 def receivedSubject(self, room, user, subject): 750 def receivedSubject(self, room, user, subject):
748 # http://xmpp.org/extensions/xep-0045.html#enter-subject 751 # http://xmpp.org/extensions/xep-0045.html#enter-subject
749 log.debug(_(u"New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject}) 752 log.debug(_(u"New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
750 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) 753 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
751 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) 754 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)
755
756 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
757 return [disco.DiscoFeature(NS_MUC)]
758
759 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
760 # TODO: manage room queries ? Bad for privacy, must be disabled by default
761 # see XEP-0045 ยง 6.7
762 return []