comparison src/plugins/plugin_xep_0277.py @ 2341:f9580b4a105a

plugin XEP-0277: added microblog namespace to disco info
author Goffi <goffi@goffi.org>
date Sun, 20 Aug 2017 17:37:43 +0200
parents 310a454c8657
children 72cbb6478f97
comparison
equal deleted inserted replaced
2340:4fd499d14b27 2341:f9580b4a105a
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C 21 from sat.core.constants import Const as C
22 from sat.core.log import getLogger 22 from sat.core.log import getLogger
23 log = getLogger(__name__) 23 log = getLogger(__name__)
24 from twisted.words.protocols.jabber import jid, error 24 from twisted.words.protocols.jabber import jid, error
25 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
25 from twisted.words.xish import domish 26 from twisted.words.xish import domish
26 from twisted.internet import defer 27 from twisted.internet import defer
27 from twisted.python import failure 28 from twisted.python import failure
28 from sat.core import exceptions 29 from sat.core import exceptions
29 from sat.tools import xml_tools 30 from sat.tools import xml_tools
31 from sat.tools import utils 32 from sat.tools import utils
32 from sat.tools.common import data_format 33 from sat.tools.common import data_format
33 34
34 # XXX: tmp.pubsub is actually used instead of wokkel version 35 # XXX: tmp.pubsub is actually used instead of wokkel version
35 from wokkel import pubsub 36 from wokkel import pubsub
37 from wokkel import disco, iwokkel
38 from zope.interface import implements
36 import uuid 39 import uuid
37 import time 40 import time
38 import dateutil 41 import dateutil
39 import calendar 42 import calendar
40 import urlparse 43 import urlparse
51 C.PI_TYPE: "XEP", 54 C.PI_TYPE: "XEP",
52 C.PI_PROTOCOLS: ["XEP-0277"], 55 C.PI_PROTOCOLS: ["XEP-0277"],
53 C.PI_DEPENDENCIES: ["XEP-0163", "XEP-0060", "TEXT-SYNTAXES"], 56 C.PI_DEPENDENCIES: ["XEP-0163", "XEP-0060", "TEXT-SYNTAXES"],
54 C.PI_RECOMMENDATIONS: ["XEP-0059", "EXTRA-PEP"], 57 C.PI_RECOMMENDATIONS: ["XEP-0059", "EXTRA-PEP"],
55 C.PI_MAIN: "XEP_0277", 58 C.PI_MAIN: "XEP_0277",
56 C.PI_HANDLER: "no", 59 C.PI_HANDLER: "yes",
57 C.PI_DESCRIPTION: _("""Implementation of microblogging Protocol""") 60 C.PI_DESCRIPTION: _("""Implementation of microblogging Protocol""")
58 } 61 }
59 62
60 63
61 class NodeAccessChangeException(Exception): 64 class NodeAccessChangeException(Exception):
95 method=self._mbGetFromMany) 98 method=self._mbGetFromMany)
96 host.bridge.addMethod("mbGetFromManyWithCommentsRTResult", ".plugin", in_sign='ss', out_sign='(ua(sssa(a{ss}a(sssaa{ss}a{ss}))a{ss}))', 99 host.bridge.addMethod("mbGetFromManyWithCommentsRTResult", ".plugin", in_sign='ss', out_sign='(ua(sssa(a{ss}a(sssaa{ss}a{ss}))a{ss}))',
97 method=self._mbGetFromManyWithCommentsRTResult, async=True) 100 method=self._mbGetFromManyWithCommentsRTResult, async=True)
98 host.bridge.addMethod("mbGetFromManyWithComments", ".plugin", in_sign='sasiia{ss}a{ss}s', out_sign='s', 101 host.bridge.addMethod("mbGetFromManyWithComments", ".plugin", in_sign='sasiia{ss}a{ss}s', out_sign='s',
99 method=self._mbGetFromManyWithComments) 102 method=self._mbGetFromManyWithComments)
103
104 def getHandler(self, client):
105 return XEP_0277_handler()
100 106
101 def _checkFeaturesCb(self, available): 107 def _checkFeaturesCb(self, available):
102 return {'available': C.BOOL_TRUE} 108 return {'available': C.BOOL_TRUE}
103 109
104 def _checkFeaturesEb(self, fail): 110 def _checkFeaturesEb(self, fail):
932 d.addCallback(getComments) 938 d.addCallback(getComments)
933 d.addCallback(lambda items_comments_data: ('', items_comments_data)) 939 d.addCallback(lambda items_comments_data: ('', items_comments_data))
934 d.addErrback(lambda failure: (unicode(failure.value), ([],{}))) 940 d.addErrback(lambda failure: (unicode(failure.value), ([],{})))
935 941
936 return self.rt_sessions.newSession(deferreds, client.profile) 942 return self.rt_sessions.newSession(deferreds, client.profile)
943
944
945 class XEP_0277_handler(XMPPHandler):
946 implements(iwokkel.IDisco)
947
948 def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
949 return [disco.DiscoFeature(NS_MICROBLOG)]
950
951 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
952 return []