当前位置: 首页>>代码示例>>Python>>正文


Python IQ.addCallback方法代码示例

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


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

示例1: on_description

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    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,代码行数:33,代码来源:xmpp.py

示例2: getStats

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
	def getStats(self, jid = "icq.netlab.cz"):
		iq = IQ(self.xmlstream, "get")
		iq['to'] = jid
		iq.addElement(("http://jabber.org/protocol/stats", "query"))

		iq.addCallback(self._statsReceived)
		iq.send()
开发者ID:mikerCZ,项目名称:spectrum,代码行数:9,代码来源:stats.py

示例3: on_presence

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
 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,代码行数:31,代码来源:xmpp.py

示例4: invalid_user

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def invalid_user(self, xs):
        iq = IQ(self.xmlstream, "set")
        iq.addElement(("jabber:iq:register", "query"))
        iq.query.addElement("username", content = self.jid.user)
        iq.query.addElement("password", content = self.password)

        iq.addCallback(self._registerResultEvent)

        iq.send()
开发者ID:Svedrin,项目名称:spectrum,代码行数:11,代码来源:tests.py

示例5: authenticated

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def authenticated(self, xs):

        presence = domish.Element((None, 'presence'))
        xs.send(presence)

        iq = IQ(self.xmlstream, "set")
        iq.addElement(("jabber:iq:register", "query"))
        iq.query.addElement("remove")

        iq.addCallback(self._result)

        iq.send()
开发者ID:Svedrin,项目名称:spectrum,代码行数:14,代码来源:tests.py

示例6: registerAccount

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def registerAccount(self, username=None, password=None):
        if username:
            self.jid.user = username
        if password:
            self.password = password

        iq = IQ(self.xmlstream, "set")
        iq.addElement(("jabber:iq:register", "query"))
        iq.query.addElement("username", content=self.jid.user)
        iq.query.addElement("password", content=self.password)

        iq.addCallback(self._registerResultEvent)
        iq.send()
开发者ID:ecmanaged,项目名称:ecm-agent,代码行数:15,代码来源:core.py

示例7: _statsReceived

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
	def _statsReceived(self, el):

		iq = IQ(self.xmlstream, "get")
		iq['to'] = el['from']
		q = iq.addElement(("http://jabber.org/protocol/stats", "query"))

		query = el.firstChildElement()
		for child in query.children:
			s = q.addElement('stat')
			s['name'] = child['name']

		iq.addCallback(self._statsDataReceived)
		iq.send()
开发者ID:mikerCZ,项目名称:spectrum,代码行数:15,代码来源:stats.py

示例8: moderate

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
 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,代码行数:15,代码来源:room.py

示例9: check_users

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def check_users(self):
        for user, value in self.users.items():
            if value['state'] is False:
                iq = IQ(self.xmlstream, 'set')
                query = domish.Element(('jabber:iq:roster', 'query'))
                item = domish.Element((None, 'item'))
                item['name'] = user
                item['jid'] = user
                item.addElement('group', content='hosts')
                query.addChild(item)
                iq.addChild(query)
                iq.addCallback(self.cloud_subscribe, user)
#                 print('send IQ: %s' % (iq.toXml().encode('utf-8')))
                iq.send()
开发者ID:bverdu,项目名称:onDemand,代码行数:16,代码来源:controller.py

示例10: authenticated

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def authenticated(self, xs):

        self.log.debug('Cloud Authenticated')
        presence = domish.Element((None, 'presence'))
        xs.send(presence)
        xs.addObserver('/presence', self.on_presence)
        xs.addObserver('/iq', self.on_iq)
        xs.addObserver('/message', self.on_event)
        disco = IQ(xs, 'get')
        disco.addElement(('http://jabber.org/protocol/disco#items', 'query'))
        disco.addCallback(self.cloud_discovered)
        disco.send()
#         self.reactor.callLater(120, xs.sendFooter)
        self.reactor.callLater(5, self.check_users)
开发者ID:bverdu,项目名称:onDemand,代码行数:16,代码来源:controller.py

示例11: _result2

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def _result2(self, iq):
        if iq['type'] != 'result':
            self.failed()
        query = iq.firstChildElement()
        if query.name != "query":
            self.failed()

        iq = IQ(self.xmlstream, "get")
        iq['to'] = transport
        iq.addElement(("jabber:iq:register", "query"))

        iq.addCallback(self._result3)

        iq.send()
开发者ID:Svedrin,项目名称:spectrum,代码行数:16,代码来源:tests.py

示例12: __call__

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
 def __call__(self, *args, **kwargs):
     d = defer.Deferred()
     self.ctx, = self.contexts
     self.get_out_object(self.ctx, args, kwargs)
     self.get_out_string(self.ctx)
     self.ctx.in_string = []
     action = IQ(self.url[0], 'set')
     for item in self.ctx.out_string:
         action.addRawXml(item)
     if action.callbacks:
         action.addCallback(self.on_response, d)
     else:
         print('wtf?')
     action.send(to=self.url[1])
     return d
开发者ID:bverdu,项目名称:onDemand,代码行数:17,代码来源:controller.py

示例13: _result

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def _result(self, iq):
        #<iq from='icq.localhost' to='[email protected]/test' id='H_24' type='result'><query xmlns='jabber:iq:register'><instructions>Enter your Jabber ID and password:</instructions><username/><password/><x xmlns='jabber:x:data' type='form'><title>Registration</title><instructions>Enter your Jabber ID and password:</instructions><field type='hidden' var='FORM_TYPE'><value>jabber:iq:register</value></field><field type='text-single' var='username' label='Network username'><required/></field><field type='text-private' var='password' label='Password'><required/></field><field type='list-single' var='language' label='Language'><value>en</value><option label='Cesky'><value>cs</value></option><option label='English'><value>en</value></option></field></x></query></iq>
        # TODO: more tests
        if iq['type'] != 'result':
            self.failed()
        query = iq.firstChildElement()
        if query.name != "query":
            self.failed()
        
        iq = IQ(self.xmlstream, "set")
        iq['to'] = transport
        iq.addElement(("jabber:iq:register", "query"))
        iq.query.addElement("username", content = client_jid1.userhost())
        iq.query.addElement("password", content = secret1)

        iq.addCallback(self._result2)

        iq.send()
开发者ID:Svedrin,项目名称:spectrum,代码行数:20,代码来源:tests.py

示例14: unsubscribe_cloud

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def unsubscribe_cloud(self, name):

        def unsubscribed(name, d, res):
            if res['type'] == 'result':
                #                 print('unsubscribed: %s' % name)
                del self.subscriptions_cloud[name]
                print('ok')
                d.callback(None)
            else:
                d.errback(Exception(res.toXml()))

        d = defer.Deferred()
        iq = IQ(self.xmlstream, 'set')
        ps = domish.Element(('http://jabber.org/protocol/pubsub', 'pubsub'))
        unsubscribe = domish.Element((None, 'unsubscribe'))
        unsubscribe['node'] = name
        unsubscribe['jid'] = self.jid.full()
        ps.addChild(unsubscribe)
        iq.addChild(ps)
        iq.addCallback(unsubscribed, name, d)
        iq.send(to='pubsub.' + self.jid.host)
        return d
开发者ID:bverdu,项目名称:onDemand,代码行数:24,代码来源:controller.py

示例15: authenticated

# 需要导入模块: from twisted.words.protocols.jabber.client import IQ [as 别名]
# 或者: from twisted.words.protocols.jabber.client.IQ import addCallback [as 别名]
    def authenticated(self, xs):
        print "Authenticated."
#         bind = IQ(xs, 'set')
# #         res = domish.Element((None, 'resource'), content=self.resource)
#         res = domish.Element(('urn:ietf:params:xml:ns:xmpp-bind', 'bind'))
#         res.addElement('resource', content=self.resource)
#         bind.addChild(res)
# #         bind['from'] = self._jid
# #         bind['to'] = self.jid.host
#         xs.send(bind)
        presence = domish.Element((None, 'presence'))
        xs.send(presence)
        xs.addObserver('/presence', self.on_presence)
        xs.addObserver('/iq', self.on_iq)
        disco = IQ(xs, 'get')
#         disco['to'] = '[email protected]/urn:schemas-upnp-org:device:MediaRenderer:1:uuid:e70e9d0e-d9eb-4748-b163-636a323e7950'
#         search = domish.Element(('http://jabber.org/protocol/disco#items', 'query'))
        disco.addElement(('http://jabber.org/protocol/disco#items', 'query'))
        disco.addCallback(self.discovered)
        disco.send()
        self.reactor.callLater(120, xs.sendFooter)
        self.reactor.callLater(5, self.check_users)
开发者ID:bverdu,项目名称:onDemand,代码行数:24,代码来源:xmpp.py


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