core (disco): use of “profile” instead of “profile_key” in several disco methods

This commit is contained in:
Goffi 2015-11-02 22:02:41 +01:00
commit 341143445b
6 changed files with 50 additions and 48 deletions

View file

@ -23,7 +23,7 @@ from sat.core.log import getLogger
log = getLogger(__name__)
from twisted.internet import defer
from twisted.words.protocols.jabber import jid
from twisted.words.xish.domish import Element, generateElementsNamed
from twisted.words.xish.domish import generateElementsNamed
from sat.core import exceptions
from wokkel import disco, data_form, iwokkel
from wokkel import rsm
@ -140,7 +140,7 @@ class GroupBlog(object):
def profileConnected(self, profile):
client = self.host.getClient(profile)
try:
yield self.host.checkFeatures((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), profile_key=profile)
yield self.host.checkFeatures((NS_PUBSUB_GROUPBLOG, NS_PUBSUB_AUTO_CREATE), profile=profile)
except exceptions.FeatureNotFound:
client.server_groupblog_available = False
log.warning(_(u"Server is not able to manage item-access pubsub, we can't use group blog"))
@ -177,7 +177,7 @@ class GroupBlog(object):
if not hasattr(client, "item_access_pubsub"):
log.debug(_('Looking for item-access powered pubsub server'))
#we don't have any pubsub server featuring item access yet
item_access_pubsubs = yield self.host.findFeaturesSet((NS_PUBSUB_AUTO_CREATE, NS_PUBSUB_CREATOR_JID_CHECK), "pubsub", "service", profile_key=profile)
item_access_pubsubs = yield self.host.findFeaturesSet((NS_PUBSUB_AUTO_CREATE, NS_PUBSUB_CREATOR_JID_CHECK), "pubsub", "service", profile=profile)
# item_access_pubsubs = yield self.host.findFeaturesSet((NS_PUBSUB_ITEM_ACCESS, NS_PUBSUB_AUTO_CREATE, NS_PUBSUB_CREATOR_JID_CHECK), "pubsub", "service", profile_key=profile)
try:
client.item_access_pubsub = item_access_pubsubs.pop()

View file

@ -99,7 +99,7 @@ class XEP_0033(object):
self.sendAndStoreMessage(mess_data, entries, profile)
log.debug("XEP-0033 took over")
raise failure.Failure(exceptions.CancelError())
d = self.host.findFeaturesSet([NS_ADDRESS], profile_key=profile)
d = self.host.findFeaturesSet([NS_ADDRESS], profile=profile)
d.addCallbacks(discoCallback, lambda dummy: discoCallback(None))
return d
@ -154,7 +154,7 @@ class XEP_0033(object):
defer_list = []
for type_, jid_ in entries:
d = defer.Deferred()
d.addCallback(self.host.findFeaturesSet, jid_=JID(JID(jid_).host), profile_key=profile)
d.addCallback(self.host.findFeaturesSet, jid_=JID(JID(jid_).host), profile=profile)
d.addCallbacks(discoCallback, errback, callbackArgs=[jid_], errbackArgs=[jid_])
d.callback([NS_ADDRESS])
defer_list.append(d)

View file

@ -100,7 +100,7 @@ class XEP_0045(object):
def assign_service(service):
client = self.host.getClient(profile)
client.muc_service = service
return self.getMUCService(profile_key=profile).addCallback(assign_service)
return self.getMUCService(profile=profile).addCallback(assign_service)
def checkClient(self, profile):
"""Check if the profile is connected and has used the MUC feature.
@ -304,14 +304,14 @@ class XEP_0045(object):
return self.clients[profile].rec_subjects.values()
@defer.inlineCallbacks
def getMUCService(self, jid_=None, profile_key=C.PROF_KEY_NONE):
def getMUCService(self, jid_=None, profile=C.PROF_KEY_NONE):
"""Return first found MUC service of an entity
@param jid_: entity which may have a MUC service, or None for our own server
@param profile_key: %(doc_profile_key)s
@param profile: %(doc_profile)s
"""
muc_service = None
services = yield self.host.findServiceEntities("conference", "text", jid_, profile_key=profile_key)
services = yield self.host.findServiceEntities("conference", "text", jid_, profile=profile)
for service in services:
if ".irc." not in service.userhost():
# FIXME:

View file

@ -27,7 +27,6 @@ from twisted.internet import defer
from wokkel import data_form
from sat.core.constants import Const as C
from sat.core.exceptions import DataError
from sat.memory.memory import Sessions
from sat.tools import xml_tools
from wokkel import disco, iwokkel
@ -84,11 +83,11 @@ class XEP_0055(object):
def _getHostServices(self, profile):
"""Return the jabber search services associated to the user host.
@param profile (unicode): %(doc_profile)s
@return: list[jid.JID]
"""
d = self.host.findFeaturesSet([NS_SEARCH], profile_key=profile)
d = self.host.findFeaturesSet([NS_SEARCH], profile=profile)
return d.addCallback(lambda set_: list(set_))
@ -125,7 +124,7 @@ class XEP_0055(object):
def _addSimpleSearchUI(self, services, main_ui, data, profile):
"""Add to the main UI a tab for the simple search.
Display a single input field and search on the main service (it actually does one search per search field and then compile the results).
@param services (list[jid.JID]): search services offered by the user server
@ -143,7 +142,7 @@ class XEP_0055(object):
sub_cont = main_ui.main_container.addTab("simple_search", label=_("Simple search"), container=xml_tools.VerticalContainer)
main_ui.changeContainer(sub_cont.append(xml_tools.PairsContainer(main_ui)))
xml_tools.dataForm2Widgets(main_ui, form)
# FIXME: add colspan attribute to divider? (we are in a PairsContainer)
main_ui.addDivider('blank')
main_ui.addDivider('blank') # here we added a blank line before the button
@ -243,7 +242,7 @@ class XEP_0055(object):
name = widget.getAttribute("name")
if adv_data.get(name):
widget.setAttribute("value", adv_data[name])
# FIXME: add colspan attribute to divider? (we are in a PairsContainer)
main_ui.addDivider('blank')
main_ui.addDivider('blank') # here we added a blank line before the button
@ -267,11 +266,11 @@ class XEP_0055(object):
def _displaySearchResult(self, main_ui, elt):
"""Display the search results.
@param main_ui (XMLUI): the main XMLUI instance
@param elt (domish.Element): form result element
"""
if [child for child in elt.children if child.name == "item"]:
if [child for child in elt.children if child.name == "item"]:
headers, xmlui_data = xml_tools.dataFormResult2XMLUIData(elt)
if "jid" in headers: # use XMLUI JidsListWidget to display the results
values = {}
@ -458,7 +457,7 @@ class XEP_0055(object):
@return: a deferred dict{unicode: unicode}
"""
d = self._getHostServices(profile)
def got_services(services):
service_jid = services[0]
d = self.host.plugins["XEP-0050"].requestCommandsList(service_jid, profile)

View file

@ -96,7 +96,7 @@ class XEP_0060(object):
@defer.inlineCallbacks
def profileConnected(self, profile):
client = self.host.getClient(profile)
pubsub_services = yield self.host.findServiceEntities("pubsub", "service", profile_key = profile)
pubsub_services = yield self.host.findServiceEntities("pubsub", "service", profile=profile)
if pubsub_services:
# we use one of the found services as our default pubsub service
client.pubsub_service = pubsub_services.pop()

View file

@ -66,7 +66,7 @@ class XEP_0115(object):
client.caps_optimize = None
if XEP_0115.cap_hash is None:
disco_d.addCallback(lambda dummy: self.host.hasFeature(NS_CAPS_OPTIMIZE, profile_key=profile))
disco_d.addCallback(lambda dummy: self.host.hasFeature(NS_CAPS_OPTIMIZE, profile=profile))
def updateOptimize(optimize):
client.caps_optimize = optimize
if optimize: