本文整理汇总了Python中pyxmpp.iq.Iq.new_query方法的典型用法代码示例。如果您正苦于以下问题:Python Iq.new_query方法的具体用法?Python Iq.new_query怎么用?Python Iq.new_query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyxmpp.iq.Iq
的用法示例。
在下文中一共展示了Iq.new_query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: request_session
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def request_session(self):
"""Request an IM session."""
stream=self.get_stream()
if not stream.version:
need_session=False
elif not stream.features:
need_session=False
else:
ctxt = stream.doc_in.xpathNewContext()
ctxt.setContextNode(stream.features)
ctxt.xpathRegisterNs("sess","urn:ietf:params:xml:ns:xmpp-session")
# jabberd2 hack
ctxt.xpathRegisterNs("jsess","http://jabberd.jabberstudio.org/ns/session/1.0")
sess_n=None
try:
sess_n=ctxt.xpathEval("sess:session or jsess:session")
finally:
ctxt.xpathFreeContext()
if sess_n:
need_session=True
else:
need_session=False
if not need_session:
self.state_changed.acquire()
self.session_established=1
self.state_changed.notify()
self.state_changed.release()
self._session_started()
else:
iq=Iq(stanza_type="set")
iq.new_query("urn:ietf:params:xml:ns:xmpp-session","session")
stream.set_response_handlers(iq,
self.__session_result,self.__session_error,self.__session_timeout)
stream.send(iq)
示例2: request_roster
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def request_roster(self):
"""Request the user's roster."""
stream=self.get_stream()
iq=Iq(stanza_type="get")
iq.new_query("jabber:iq:roster")
stream.set_response_handlers(iq,
self.__roster_result,self.__roster_error,self.__roster_timeout)
stream.set_iq_set_handler("query","jabber:iq:roster",self.__roster_push)
stream.send(iq)
示例3: configure_room
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def configure_room(self, form):
"""
Configure the room using the provided data.
Do nothing if the provided form is of type 'cancel'.
:Parameters:
- `form`: the configuration parameters. Should be a 'submit' form made by filling-in
the configuration form retireved using `self.request_configuration_form` or
a 'cancel' form.
:Types:
- `form`: `Form`
:return: id of the request stanza or `None` if a 'cancel' form was provieded.
:returntype: `unicode`
"""
if form.type == "cancel":
return None
elif form.type != "submit":
raise ValueError, "A 'submit' form required to configure a room"
iq = Iq(to_jid = self.room_jid.bare(), stanza_type = "set")
query = iq.new_query(MUC_OWNER_NS, "query")
form.as_xml(query)
self.manager.stream.set_response_handlers(
iq, self.process_configuration_success, self.process_configuration_error)
self.manager.stream.send(iq)
return iq.get_id()
示例4: request_configuration_form
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def request_configuration_form(self):
"""
Request a configuration form for the room.
When the form is received `self.handler.configuration_form_received` will be called.
When an error response is received then `self.handler.error` will be called.
:return: id of the request stanza.
:returntype: `unicode`
"""
iq = Iq(to_jid = self.room_jid.bare(), stanza_type = "get")
iq.new_query(MUC_OWNER_NS, "query")
self.manager.stream.set_response_handlers(
iq, self.process_configuration_form_success, self.process_configuration_form_error)
self.manager.stream.send(iq)
return iq.get_id()
示例5: query_get
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def query_get(self, jid, handler) :
stream = self.client.get_stream()
iq = Iq(to_jid=jid, stanza_type="get")
q=iq.new_query(VCARD_NS, "vCard")
stream.set_response_handlers(iq, self.on_get_result, self.on_get_error)
stream.send(iq)
self.handler = handler
示例6: query_set
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def query_set(self, vcard) :
stream = self.client.get_stream()
new_id = stream.generate_id()
iq = Iq(None, None, None, "set", new_id)
node=iq.new_query(VCARD_NS, "vCard")
vcard.as_xml(node)
stream.set_response_handlers(iq, self.on_set_result, self.on_set_error)
stream.send(iq)
示例7: make_roster_push
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def make_roster_push(self):
"""
Make "roster push" IQ stanza from the item representing roster update
request.
"""
iq=Iq(stanza_type="set")
q=iq.new_query(ROSTER_NS)
self.as_xml(parent=q, doc=common_doc)
return iq
示例8: _plain_auth_stage2
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def _plain_auth_stage2(self, _unused):
"""Do the second stage (<iq type='set'/>) of legacy "plain"
authentication.
[client only]"""
iq=Iq(stanza_type="set")
q=iq.new_query("jabber:iq:auth")
q.newTextChild(None,"username",to_utf8(self.my_jid.node))
q.newTextChild(None,"resource",to_utf8(self.my_jid.resource))
q.newTextChild(None,"password",to_utf8(self.password))
self.send(iq)
self.set_response_handlers(iq,self.auth_finish,self.auth_error)
iq.free()
示例9: _auth_stage1
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def _auth_stage1(self):
"""Do the first stage (<iq type='get'/>) of legacy ("plain" or
"digest") authentication.
[client only]"""
iq=Iq(stanza_type="get")
q=iq.new_query("jabber:iq:auth")
q.newTextChild(None,"username",to_utf8(self.my_jid.node))
q.newTextChild(None,"resource",to_utf8(self.my_jid.resource))
self.send(iq)
self.set_response_handlers(iq,self.auth_stage2,self.auth_error,
self.auth_timeout,timeout=60)
iq.free()
示例10: _digest_auth_stage2
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def _digest_auth_stage2(self, _unused):
"""Do the second stage (<iq type='set'/>) of legacy "digest"
authentication.
[client only]"""
iq=Iq(stanza_type="set")
q=iq.new_query("jabber:iq:auth")
q.newTextChild(None,"username",to_utf8(self.my_jid.node))
q.newTextChild(None,"resource",to_utf8(self.my_jid.resource))
digest = hashlib.sha1(to_utf8(self.stream_id)+to_utf8(self.password)).hexdigest()
q.newTextChild(None,"digest",digest)
self.send(iq)
self.set_response_handlers(iq,self.auth_finish,self.auth_error)
iq.free()
示例11: query_get_server
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def query_get_server(self) :
stream = self.client.get_stream()
discoIq = Iq(None, self.client.jid, self.client.jid.domain, "get", stream.generate_id())
discoIq.new_query('http://jabber.org/protocol/disco#info')
stream.set_response_handlers(discoIq, self.on_get_result, self.on_get_error)
stream.send(discoIq)
示例12: make_get
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def make_get(gtalk_protocol):
iq = Iq(stanza_type="get")
q = iq.new_query(SHARED_STATUS_NS)
q.setProp("version", "2")
return iq
示例13: make_get
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def make_get(digsby_protocol):
iq = Iq(stanza_type="get")
iq.set_to(digsby_protocol.jid.domain)
q = iq.new_query(DIGSBY_WIDGETS_NS)
return iq
示例14: make_get
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def make_get(gtalk_protocol):
iq = Iq(stanza_type="get")
_q = iq.new_query(GOOGLE_MAIL_NOTIFY_NS)
return iq
示例15: make_push
# 需要导入模块: from pyxmpp.iq import Iq [as 别名]
# 或者: from pyxmpp.iq.Iq import new_query [as 别名]
def make_push(acct, digsby_protocol):
iq=Iq(stanza_type="set")
iq.set_to(digsby_protocol.jid.domain)
q = iq.new_query(DIGSBY_ACCOUNTS_NS)
acct.as_xml(parent=q)
return iq