plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
This commit is contained in:
parent
690b1c2213
commit
fe5cc0ac0a
1 changed files with 28 additions and 1 deletions
|
|
@ -42,10 +42,10 @@ NS_NODE_PREFIX = 'urn:xmpp:groupblog:'
|
||||||
#NS_PUBSUB_EXP = 'http://goffi.org/protocol/pubsub' #for non official features
|
#NS_PUBSUB_EXP = 'http://goffi.org/protocol/pubsub' #for non official features
|
||||||
NS_PUBSUB_EXP = NS_PUBSUB # XXX: we can't use custom namespace as Wokkel's PubSubService use official NS
|
NS_PUBSUB_EXP = NS_PUBSUB # XXX: we can't use custom namespace as Wokkel's PubSubService use official NS
|
||||||
NS_PUBSUB_ITEM_ACCESS = NS_PUBSUB_EXP + "#item-access"
|
NS_PUBSUB_ITEM_ACCESS = NS_PUBSUB_EXP + "#item-access"
|
||||||
|
NS_PUBSUB_GROUPBLOG = NS_PUBSUB_EXP + "#groupblog"
|
||||||
NS_PUBSUB_CREATOR_JID_CHECK = NS_PUBSUB_EXP + "#creator-jid-check"
|
NS_PUBSUB_CREATOR_JID_CHECK = NS_PUBSUB_EXP + "#creator-jid-check"
|
||||||
NS_PUBSUB_ITEM_CONFIG = NS_PUBSUB_EXP + "#item-config"
|
NS_PUBSUB_ITEM_CONFIG = NS_PUBSUB_EXP + "#item-config"
|
||||||
NS_PUBSUB_AUTO_CREATE = NS_PUBSUB + "#auto-create"
|
NS_PUBSUB_AUTO_CREATE = NS_PUBSUB + "#auto-create"
|
||||||
TYPE_COLLECTION = 'collection'
|
|
||||||
ACCESS_TYPE_MAP = { 'PUBLIC': 'open',
|
ACCESS_TYPE_MAP = { 'PUBLIC': 'open',
|
||||||
'GROUP': 'roster',
|
'GROUP': 'roster',
|
||||||
'JID': None, #JID is not yet managed
|
'JID': None, #JID is not yet managed
|
||||||
|
|
@ -142,6 +142,33 @@ class GroupBlog(object):
|
||||||
def getHandler(self, profile):
|
def getHandler(self, profile):
|
||||||
return GroupBlog_handler()
|
return GroupBlog_handler()
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def profileConnected(self, profile):
|
||||||
|
client = self.host.getClient(profile)
|
||||||
|
groupblog_services = yield self.host.findFeaturesSet((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), "pubsub", "service", profile_key=profile)
|
||||||
|
if groupblog_services:
|
||||||
|
# we use one of the found services as our default pubsub service
|
||||||
|
client.groupblog_service = groupblog_services.pop()
|
||||||
|
log.info(_(u"item-access powered pubsub service found: {}").format(client.groupblog_service.full()))
|
||||||
|
else:
|
||||||
|
client.groupblog_service = None
|
||||||
|
log.warning(_(u"No item-access powered pubsub server found, can't use group blog"))
|
||||||
|
|
||||||
|
def getFeatures(self, profile):
|
||||||
|
try:
|
||||||
|
client = self.host.getClient(profile)
|
||||||
|
except exceptions.ProfileNotSetError:
|
||||||
|
return {}
|
||||||
|
try:
|
||||||
|
return {'service': client.groupblog_service.full() if client.groupblog_service is not None else ''}
|
||||||
|
except AttributeError:
|
||||||
|
if self.host.isConnected(profile):
|
||||||
|
log.debug("Profile is not connected, service is not checked yet")
|
||||||
|
else:
|
||||||
|
log.error("Service should be available !")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _initialise(self, profile_key):
|
def _initialise(self, profile_key):
|
||||||
"""Check that the data for this profile are initialised, and do it else
|
"""Check that the data for this profile are initialised, and do it else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue