wokkel integration, part II
- disco client - fallback handler (for unmanaged iq requests) - software version (XEP-0092)
This commit is contained in:
parent
4c7d7563d3
commit
af75e43558
2 changed files with 21 additions and 28 deletions
45
sat.tac
45
sat.tac
|
|
@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
client_name = u'SàT (Salut à toi)'
|
||||||
|
client_version = '0.0.1'
|
||||||
|
|
||||||
from twisted.application import internet, service
|
from twisted.application import internet, service
|
||||||
from twisted.internet import glib2reactor, protocol, task
|
from twisted.internet import glib2reactor, protocol, task
|
||||||
|
|
@ -30,7 +32,7 @@ from twisted.words.xish import domish
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
import pdb
|
import pdb
|
||||||
|
|
||||||
from wokkel import client, disco, xmppim
|
from wokkel import client, disco, xmppim, generic
|
||||||
|
|
||||||
from sat_bridge.DBus import DBusBridge
|
from sat_bridge.DBus import DBusBridge
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -140,7 +142,6 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
|
||||||
status or "", int(priority))
|
status or "", int(priority))
|
||||||
|
|
||||||
#now it's time to notify frontends
|
#now it's time to notify frontends
|
||||||
pdb.set_trace()
|
|
||||||
self.host.bridge.presenceUpdate(entity.full(), "", show or "",
|
self.host.bridge.presenceUpdate(entity.full(), "", show or "",
|
||||||
status or "", int(priority))
|
status or "", int(priority))
|
||||||
|
|
||||||
|
|
@ -169,6 +170,10 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
|
||||||
def unsubscribeReceived(self, entity):
|
def unsubscribeReceived(self, entity):
|
||||||
debug ("unsubscription asked for [%s]" % entity)
|
debug ("unsubscription asked for [%s]" % entity)
|
||||||
|
|
||||||
|
class SatDiscoProtocol(disco.DiscoClientProtocol):
|
||||||
|
def __init__(self, host):
|
||||||
|
disco.DiscoClientProtocol.__init__(self)
|
||||||
|
|
||||||
class SAT(service.Service):
|
class SAT(service.Service):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -235,6 +240,12 @@ class SAT(service.Service):
|
||||||
self.presence = SatPresenceProtocol(self)
|
self.presence = SatPresenceProtocol(self)
|
||||||
self.presence.setHandlerParent(self.xmppclient)
|
self.presence.setHandlerParent(self.xmppclient)
|
||||||
|
|
||||||
|
self.fallBack = generic.FallbackHandler()
|
||||||
|
self.fallBack.setHandlerParent(self.xmppclient)
|
||||||
|
|
||||||
|
self.versionHandler = generic.VersionHandler(unicode(client_name), client_version)
|
||||||
|
self.versionHandler.setHandlerParent(self.xmppclient)
|
||||||
|
|
||||||
self.xmppclient.startService()
|
self.xmppclient.startService()
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
|
|
@ -272,17 +283,15 @@ class SAT(service.Service):
|
||||||
|
|
||||||
#FIXME:tmp
|
#FIXME:tmp
|
||||||
self.xmlstream.addObserver("/iq[@type='set' or @type='get']", self.iqCb)
|
self.xmlstream.addObserver("/iq[@type='set' or @type='get']", self.iqCb)
|
||||||
"""
|
|
||||||
###FIXME: tmp disco ###
|
###FIXME: tmp disco ###
|
||||||
#self.discoHandler = disco.discoHandler()
|
self.disco = SatDiscoProtocol(self)
|
||||||
self.memory.registerFeature("http://jabber.org/protocol/disco#info")
|
self.disco.setHandlerParent(self.xmppclient)
|
||||||
self.disco(self.memory.getParamV("Server", "Connection"), self.serverDisco)
|
self.disco.requestInfo(jid.JID(self.memory.getParamV("Server", "Connection"))).addCallback(self.serverDisco)
|
||||||
#we now send our presence status
|
#we now send our presence status
|
||||||
|
|
||||||
# add a callback for the messages
|
# add a callback for the messages
|
||||||
|
|
||||||
#reactor.callLater(2,self.sendFile,"goffi2@jabber.goffi.int/Psi", "/tmp/fakefile")
|
#reactor.callLater(2,self.sendFile,"goffi2@jabber.goffi.int/Psi", "/tmp/fakefile")
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def sendMessage(self,to,msg,type='chat'):
|
def sendMessage(self,to,msg,type='chat'):
|
||||||
|
|
@ -318,16 +327,6 @@ class SAT(service.Service):
|
||||||
|
|
||||||
## jabber methods ##
|
## jabber methods ##
|
||||||
|
|
||||||
def disco (self, item, callback, node=None):
|
|
||||||
"""XEP-0030 Service discovery Feature."""
|
|
||||||
"""disco=client.IQ(self.xmlstream,'get')
|
|
||||||
disco["from"]=self.me.full()
|
|
||||||
disco["to"]=item
|
|
||||||
disco.addElement(('http://jabber.org/protocol/disco#info', 'query'))
|
|
||||||
disco.addCallback(callback)
|
|
||||||
disco.send()"""
|
|
||||||
|
|
||||||
|
|
||||||
def setPresence(self, to="", type="", show="", status="", priority=0):
|
def setPresence(self, to="", type="", show="", status="", priority=0):
|
||||||
"""Send our presence information"""
|
"""Send our presence information"""
|
||||||
if not type in ["", "unavailable", "subscribed", "subscribe",
|
if not type in ["", "unavailable", "subscribed", "subscribe",
|
||||||
|
|
@ -385,13 +384,11 @@ class SAT(service.Service):
|
||||||
|
|
||||||
def serverDisco(self, disco):
|
def serverDisco(self, disco):
|
||||||
"""xep-0030 Discovery Protocol."""
|
"""xep-0030 Discovery Protocol."""
|
||||||
for element in disco.firstChildElement().elements():
|
for feature in disco.features:
|
||||||
if element.name=="feature":
|
debug ("Feature found: %s",feature)
|
||||||
debug ("Feature dectetee: %s",element["var"])
|
self.server_features.append(feature)
|
||||||
self.server_features.append(element["var"])
|
for cat, type in disco.identities:
|
||||||
elif element.name=="identity":
|
debug ("Identity found: [%s/%s] %s" % (cat, type, disco.identities[(cat,type)]))
|
||||||
debug ("categorie= %s",element["category"])
|
|
||||||
debug ("features= %s",self.server_features)
|
|
||||||
|
|
||||||
## Generic HMI ##
|
## Generic HMI ##
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,3 @@ class Memory:
|
||||||
if not self.params.has_key(namespace):
|
if not self.params.has_key(namespace):
|
||||||
self.params[namespace]={}
|
self.params[namespace]={}
|
||||||
self.params[namespace][name]=[value,type];
|
self.params[namespace][name]=[value,type];
|
||||||
|
|
||||||
def registerFeature(self, feature, callback=None):
|
|
||||||
self.features[feature]=callback
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue