• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python client.IQ类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.words.protocols.jabber.client.IQ的典型用法代码示例。如果您正苦于以下问题:Python IQ类的具体用法?Python IQ怎么用?Python IQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了IQ类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test

def test(q, bus, conn, stream):
    # This sidecar sends a stanza, and waits for a reply, before being
    # created.
    pattern = EventPattern('stream-iq', to='sidecar.example.com',
        query_ns='http://example.com/sidecar')
    call_async(q, conn.Sidecars1, 'EnsureSidecar', TEST_PLUGIN_IFACE + ".IQ")
    e = q.expect_many(pattern)[0]

    # The server said yes, so we should get a sidecar back!
    acknowledge_iq(stream, e.stanza)
    q.expect('dbus-return', method='EnsureSidecar')

    identities = ["test/app-list//Test"]
    features = ["com.example.test1", "com.example.test2"]
    ver = compute_caps_hash(identities, features, {})

    iq = IQ(stream, "get")
    query = iq.addElement((ns.DISCO_INFO, 'query'))
    query['node'] = ns.GABBLE_CAPS + '#' + ver
    stream.send(iq)
    e = q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info')

    returned_features = [feature['var']
        for feature in xpath.queryForNodes('/iq/query/feature', e.stanza)]
    assertEquals(features, returned_features)

    returned_identities = [identity['category'] + "/" + identity['type']+"//" + identity['name']
        for identity in xpath.queryForNodes('/iq/query/identity', e.stanza)]
    assertEquals(identities, returned_identities)

    new_ver = compute_caps_hash(returned_identities, returned_features, {})
    assertEquals(new_ver, ver)
开发者ID:Thaodan,项目名称:telepathy-gabble,代码行数:32,代码来源:sidecar-own-caps.py


示例2: on_presence

 def on_presence(self, presence):
     print('received presence: %s' % presence.toXml().encode('utf-8'))
     user, host, res = parse(presence['from'])
     jid = '@'.join((user, host))
     if presence.hasAttribute('type'):
         if presence['type'] == 'subscribe':
             if jid in self.users:
                 print('received subscription')
                 if self.users[jid] is False:
                     iq = IQ(self.xmlstream, 'set')
                     query = domish.Element(('jabber:iq:roster', 'query'))
                     item = domish.Element((None, 'item'))
                     item['jid'] = jid
                     item['name'] = jid
                     item.addElement('group', content='controllers')
                     query.addChild(item)
                     iq.addChild(query)
                     iq.addCallback(self.subscribed, jid)
                     self.xmlstream.send(iq)
                     pres = domish.Element((None, 'presence'))
                     pres['type'] = 'subscribed'
                     pres['to'] = jid
                     self.xmlstream.send(pres)
                     
             else:
                 presence = domish.Element((None, 'presence'))
                 presence['type'] = 'unsubscribed'
                 presence['to'] = presence['from']
                 self.xmlstream.send(presence)
开发者ID:bverdu,项目名称:onDemand,代码行数:29,代码来源:xmpp.py


示例3: sync_stream

def sync_stream(q, xmpp_connection):
    """Used to ensure that Salut has processed all stanzas sent to it on this
       xmpp_connection."""

    iq = IQ(None, "get")
    iq.addElement(('http://jabber.org/protocol/disco#info', 'query'))
    xmpp_connection.send(iq)
    q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info')
开发者ID:freedesktop-unofficial-mirror,项目名称:telepathy__telepathy-salut,代码行数:8,代码来源:saluttest.py


示例4: send_roster_push

def send_roster_push(stream, jid, groups):
    iq = IQ(stream, 'set')
    query = iq.addElement((ns.ROSTER, 'query'))
    item = query.addElement('item')
    item['jid'] = jid
    item['subscription'] = 'both'
    for group in groups:
        item.addElement('group', content=group)
    stream.send(iq)
开发者ID:mlundblad,项目名称:telepathy-gabble,代码行数:9,代码来源:groups.py


示例5: send_roster_iq

 def send_roster_iq(stream, jid, subscription):
     iq = IQ(stream, "set")
     iq['id'] = 'push'
     query = iq.addElement('query')
     query['xmlns'] = ns.ROSTER
     item = query.addElement('item')
     item['jid'] = jid
     item['subscription'] = subscription
     stream.send(iq)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:9,代码来源:test-roster-item-deletion.py


示例6: _send_socks5_reply

 def _send_socks5_reply(self, id, stream_used):
     result = IQ(self.stream, 'result')
     result['id'] = id
     result['from'] = self.target
     result['to'] = self.initiator
     query = result.addElement((ns.BYTESTREAMS, 'query'))
     streamhost_used = query.addElement((None, 'streamhost-used'))
     streamhost_used['jid'] = stream_used
     result.send()
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:9,代码来源:bytestream.py


示例7: send_not_found

 def send_not_found(self, id):
     iq = IQ(self.stream, 'error')
     iq['to'] = self.initiator
     iq['from'] = self.target
     iq['id'] = id
     error = iq.addElement(('', 'error'))
     error['type'] = 'cancel'
     error['code'] = '404'
     self.stream.send(iq)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:9,代码来源:bytestream.py


示例8: make_result_iq

def make_result_iq(iq):
    result = IQ(None, "result")
    result["id"] = iq["id"]
    query = iq.firstChildElement()

    if query:
        result.addElement((query.uri, query.name))

    return result
开发者ID:freedesktop-unofficial-mirror,项目名称:telepathy__telepathy-salut,代码行数:9,代码来源:saluttest.py


示例9: test

def test(q, bus, conn, stream):
    self_presence = q.expect('stream-presence')

    c = xpath.queryForNodes('/presence/c', self_presence.stanza)[0]

    jid = '[email protected]/omg'

    # Gabble shouldn't send any disco requests to our contact during this test.
    q.forbid_events([
        EventPattern('stream-iq', to=jid, iq_type='get',
            query_ns=ns.DISCO_INFO),
    ])

    # Check that Gabble doesn't disco other clients with the same caps hash.
    p = make_presence(jid,
        caps={'node': c['node'],
              'hash': c['hash'],
              'ver':  c['ver'],
             })
    stream.send(p)
    sync_stream(q, stream)

    # Check that Gabble doesn't disco its own ext='' bundles (well, its own
    # bundles as advertised by Gabbles that don't do hashed caps)
    p = make_presence(jid,
        caps={'node': c['node'],
              'ver':  c['ver'],
              # omitting hash='' so Gabble doesn't ignore ext=''
              'ext':  'voice-v1 video-v1',
            })
    stream.send(p)
    sync_stream(q, stream)

    # Advertise some different capabilities, to change our own caps hash.
    add = [(cs.CHANNEL_TYPE_STREAMED_MEDIA, 2L**32-1),
           (cs.CHANNEL_TYPE_STREAM_TUBE, 2L**32-1),
           (cs.CHANNEL_TYPE_STREAM_TUBE, 2L**32-1)]
    remove = []
    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)

    self_presence = q.expect('stream-presence')
    c_ = xpath.queryForNodes('/presence/c', self_presence.stanza)[0]
    assertNotEquals(c['ver'], c_['ver'])

    # But then someone asks us for our old caps
    iq = IQ(stream, 'get')
    iq['from'] = jid
    query = iq.addElement((ns.DISCO_INFO, 'query'))
    query['node'] = c['node'] + '#' + c['ver']
    stream.send(iq)

    # Gabble should still know what they are, and reply. This is actually quite
    # important: there's a bug in iChat where if you return an error to a disco
    # query, it just asks again, and again, and again...
    reply = q.expect('stream-iq', to=jid)
    assertEquals('result', reply.iq_type)
开发者ID:jku,项目名称:telepathy-gabble,代码行数:56,代码来源:trust-thyself.py


示例10: _cb_bare_jid_disco_iq

 def _cb_bare_jid_disco_iq(self, iq):
     # Additionally, Prosody 0.6.1 doesn't like us discoing our own bare
     # JID, and responds with an error which doesn't have the 'from'
     # attribute. Wocky used to discard this, but now tolerates it.
     result = IQ(self, 'error')
     result['id'] = iq['id']
     error = result.addElement((None, 'error'))
     error['type'] = 'cancel'
     error.addElement((ns.STANZA, 'service-unavailable'))
     self.send(result)
开发者ID:Thaodan,项目名称:telepathy-gabble,代码行数:10,代码来源:pep-support.py


示例11: respondToInitialIq

 def respondToInitialIq(self, iq):
     result = IQ(self.xmlstream, "result")
     result["id"] = iq["id"]
     query = result.addElement('query')
     query["xmlns"] = "jabber:iq:auth"
     query.addElement('username', content='test')
     query.addElement('password')
     query.addElement('digest')
     query.addElement('resource')
     self.xmlstream.send(result)
开发者ID:Thaodan,项目名称:telepathy-gabble,代码行数:10,代码来源:gabbletest.py


示例12: sync_stream

def sync_stream(q, stream):
    """Used to ensure that Gabble has processed all stanzas sent to it."""

    iq = IQ(stream, "get")
    id = iq['id']
    iq.addElement(('http://jabber.org/protocol/disco#info', 'query'))
    stream.send(iq)
    q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info',
        predicate=(lambda event:
            event.stanza['id'] == id and event.iq_type == 'result'))
开发者ID:Thaodan,项目名称:telepathy-gabble,代码行数:10,代码来源:gabbletest.py


示例13: repeat_previous_vcard

def repeat_previous_vcard(stream, iq, previous):
    result = IQ(stream, 'result')
    result['id'] = iq['id']
    to = iq.getAttribute('to')

    if to is not None:
        result["from"] = to

    result.addRawXml(previous.firstChildElement().toXml())
    stream.send(result)
开发者ID:Thaodan,项目名称:telepathy-gabble,代码行数:10,代码来源:set-contact-info.py


示例14: initialIq

 def initialIq(self, iq):
     result = IQ(self.xmlstream, "result")
     result["id"] = iq["id"]
     query = result.addElement('query')
     query["xmlns"] = "jabber:iq:auth"
     query.addElement('username', content='test')
     query.addElement('password')
     query.addElement('digest')
     query.addElement('resource')
     self.xmlstream.addOnetimeObserver('/iq/query/username', self.secondIq)
     self.xmlstream.send(result)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:11,代码来源:gabbletest.py


示例15: make_result_iq

def make_result_iq(stream, iq, add_query_node=True):
    result = IQ(stream, "result")
    result["id"] = iq["id"]
    to = iq.getAttribute('to')
    if to is not None:
        result["from"] = to
    query = iq.firstChildElement()

    if query and add_query_node:
        result.addElement((query.uri, query.name))

    return result
开发者ID:Thaodan,项目名称:telepathy-gabble,代码行数:12,代码来源:gabbletest.py


示例16: _send_socks5_init

 def _send_socks5_init(self, port):
     iq = IQ(self.stream, 'set')
     iq['to'] = self.target
     iq['from'] = self.initiator
     query = iq.addElement((ns.BYTESTREAMS, 'query'))
     query['sid'] = self.stream_id
     query['mode'] = 'tcp'
     for jid, host in self.hosts:
         streamhost = query.addElement('streamhost')
         streamhost['jid'] = jid
         streamhost['host'] = host
         streamhost['port'] = str(port)
     self.stream.send(iq)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:13,代码来源:bytestream.py


示例17: moderate

 def moderate(self, jn, jid_nick, ra, set_to, reason=None):
  if not reason: reason = self.bot.nick
  packet = IQ(self.globalbot.wrapper.x, 'set')
  query = packet.addElement('query', 'http://jabber.org/protocol/muc#admin')
  i = query.addElement('item')
  i[jn] = jid_nick
  i[ra] = set_to
  i.addElement('reason').addContent(reason)
  d = Deferred()
  packet.addCallback(d.callback)
  #print packet.toXml()
  callFromThread(packet.send, self.jid)
  return d
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:13,代码来源:room.py


示例18: bindIq

    def bindIq(self, iq):
        resource = xpath.queryForString('/iq/bind/resource', iq)
        if self.resource is not None:
            assertEquals(self.resource, resource)
        else:
            assert resource is not None

        result = IQ(self.xmlstream, "result")
        result["id"] = iq["id"]
        bind = result.addElement((NS_XMPP_BIND, 'bind'))
        jid = bind.addElement('jid', content=('[email protected]/%s' % resource))
        self.xmlstream.send(result)

        self.xmlstream.dispatch(self.xmlstream, xmlstream.STREAM_AUTHD_EVENT)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:14,代码来源:gabbletest.py


示例19: on_description

    def on_description(self, iq):
#         print(
#             'Received description from %s: %s'
#             % (iq['from'], iq.toXml().encode('utf-8')))
        pause = IQ(self.xmlstream, 'set')
        pause['to'] = iq['from']
#         enveloppe = domish.Element(
#             ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'))
        enveloppe = domish.Element(
            ('http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'), localPrefixes={'s': 'http://schemas.xmlsoap.org/soap/envelope/'})
        enveloppe['s:encodingStyle'] = "http://schemas.xmlsoap.org/soap/encoding/"
        header = domish.Element((None, 's:Header'))
#         header = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Header'))
        header['mustUnderstand'] = "1"
        uc = domish.Element(('urn:schemas-upnp-org:cloud-1-0', 'uc'))
        uc['serviceId'] = 'urn:av-openhome-org:serviceId:Playlist'
        header.addChild(uc)
        enveloppe.addChild(header)
        body = domish.Element((None, 's:Body'))
#         body = domish.Element(('http://schemas.xmlsoap.org/soap/envelope/', 'Body'))
        action = domish.Element(
            ('urn:av-openhome-org:service:Playlist:1', 'Read'), localPrefixes={'u': 'urn:av-openhome-org:service:Playlist:1'})
#         action = domish.Element(
#             ('urn:av-openhome-org:service:Playlist:1', 'Pause'))
        body.addChild(action)
        enveloppe.addChild(body)
        pause.addChild(enveloppe)
        pause.addCallback(self.paused)
        print('send pause')
        print(pause.toXml())
        pause.send()
开发者ID:bverdu,项目名称:onDemand,代码行数:31,代码来源:xmpp.py


示例20: _gtalk_stanza

    def _gtalk_stanza(self, action):
        iq = IQ(self.stream, 'set')
        iq['from'] = self.remote_jid
        iq['to'] = self.local_jid
        sess = domish.Element(("http://www.google.com/session", 'session'))
        if self.direction == 'incoming':
            sess['initiator'] = self.remote_jid
        elif self.direction == 'outgoing':
            sess['initiator'] = self.local_jid

        sess['type'] = action
        sess['id'] = self.session_id
        iq.addChild(sess)
        return (iq, sess)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:14,代码来源:jingletest.py



注:本文中的twisted.words.protocols.jabber.client.IQ类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python error.exceptionFromStanza函数代码示例发布时间:2022-05-27
下一篇:
Python irc.IRCClient类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap