當前位置: 首頁>>代碼示例>>Python>>正文


Python iq.Iq類代碼示例

本文整理匯總了Python中pyxmpp.iq.Iq的典型用法代碼示例。如果您正苦於以下問題:Python Iq類的具體用法?Python Iq怎麽用?Python Iq使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Iq類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: configure_room

    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()
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:27,代碼來源:muc.py

示例2: __init__

    def __init__(self,xmlnode=None,from_jid=None,to_jid=None,stanza_type=None,stanza_id=None,
            error=None,error_cond=None):
        """Initialize an `Iq` object.

        :Parameters:
            - `xmlnode`: XML node to_jid be wrapped into the `Iq` object
              or other Iq object to be copied. If not given then new
              presence stanza is created using following parameters.
            - `from_jid`: sender JID.
            - `to_jid`: recipient JID.
            - `stanza_type`: staza type: one of: "get", "set", "result" or "error".
            - `stanza_id`: stanza id -- value of stanza's "id" attribute. If not
              given, then unique for the session value is generated.
            - `error_cond`: error condition name. Ignored if `stanza_type` is not "error".
        :Types:
            - `xmlnode`: `unicode` or `libxml2.xmlNode` or `Iq`
            - `from_jid`: `JID`
            - `to_jid`: `JID`
            - `stanza_type`: `unicode`
            - `stanza_id`: `unicode`
            - `error_cond`: `unicode`"""
        MucStanzaExt.__init__(self)
        Iq.__init__(self,xmlnode,from_jid=from_jid,to_jid=to_jid,
                stanza_type=stanza_type,stanza_id=stanza_id,
                error=error,error_cond=error_cond)
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:25,代碼來源:muccore.py

示例3: request_session

    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)
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:35,代碼來源:client.py

示例4: make_push

    def make_push(self, digsby_protocol):
        'Creates a set stanza.'

        iq=Iq(stanza_type="set")
        iq.set_to(digsby_protocol.jid.domain)
        self.as_xml(parent=iq.get_node())
        return iq
開發者ID:AlexUlrich,項目名稱:digsby,代碼行數:7,代碼來源:abstract_blob.py

示例5: query_get

	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
開發者ID:walker8088,項目名稱:easyworld,代碼行數:7,代碼來源:discomgr.py

示例6: test_get_lang_class_from_node

 def test_get_lang_class_from_node(self):
     iq = Iq(from_jid = "[email protected]", \
             to_jid = "[email protected]", \
             stanza_type = "get")
     iq_node = iq.get_node()
     iq_node.setLang("fr")
     lang = self.lang.get_lang_class_from_node(iq_node)
     self.assertEquals(lang, Lang.fr)
開發者ID:dax,項目名稱:jmc,代碼行數:8,代碼來源:lang.py

示例7: query_set

	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)
開發者ID:walker8088,項目名稱:easyworld,代碼行數:8,代碼來源:discomgr.py

示例8: make_roster_push

 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
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:9,代碼來源:roster.py

示例9: request_roster

 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)
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:9,代碼來源:client.py

示例10: fetch

 def fetch(self):
     """Initialize the Service Discovery process."""
     from pyxmpp.iq import Iq
     jid,node = self.address
     iq = Iq(to_jid = jid, stanza_type = "get")
     disco = self.disco_class(node)
     iq.add_content(disco.xmlnode)
     self.stream.set_response_handlers(iq,self.__response, self.__error,
             self.__timeout)
     self.stream.send(iq)
開發者ID:AlexUlrich,項目名稱:digsby,代碼行數:10,代碼來源:disco.py

示例11: _auth_stage1

    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()
開發者ID:AlexUlrich,項目名稱:digsby,代碼行數:13,代碼來源:clientstream.py

示例12: _plain_auth_stage2

    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()
開發者ID:AlexUlrich,項目名稱:digsby,代碼行數:13,代碼來源:clientstream.py

示例13: request_configuration_form

    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()
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:16,代碼來源:muc.py

示例14: _post_connect

 def _post_connect(self):
     """Initialize authentication when the connection is established
     and we are the initiator."""
     if not self.initiator:
         if "plain" in self.auth_methods or "digest" in self.auth_methods:
             self.set_iq_get_handler("query","jabber:iq:auth",
                         self.auth_in_stage1)
             self.set_iq_set_handler("query","jabber:iq:auth",
                         self.auth_in_stage2)
     elif self.registration_callback:
         iq = Iq(stanza_type = "get")
         iq.set_content(Register())
         self.set_response_handlers(iq, self.registration_form_received, self.registration_error)
         self.send(iq)
         return
     ClientStream._post_connect(self)
開發者ID:AlexUlrich,項目名稱:digsby,代碼行數:16,代碼來源:clientstream.py

示例15: _digest_auth_stage2

    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()
開發者ID:AlexUlrich,項目名稱:digsby,代碼行數:16,代碼來源:clientstream.py


注:本文中的pyxmpp.iq.Iq類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。