wokkel integration part III + memory saved again
- disco handler (plugins handled)
This commit is contained in:
parent
af75e43558
commit
fe0cf89f64
1 changed files with 86 additions and 42 deletions
|
|
@ -27,6 +27,19 @@ import os.path
|
|||
from twisted.internet import reactor #FIXME best way ???
|
||||
import pdb
|
||||
|
||||
from zope.interface import implements
|
||||
|
||||
try:
|
||||
from twisted.words.protocols.xmlstream import XMPPHandler
|
||||
except ImportError:
|
||||
from wokkel.subprotocols import XMPPHandler
|
||||
|
||||
from wokkel import disco, iwokkel
|
||||
|
||||
IQ_SET = '/iq[@type="set"]'
|
||||
NS_SI = 'http://jabber.org/protocol/si'
|
||||
SI_REQUEST = IQ_SET + '/si[@xmlns="' + NS_SI + '"]'
|
||||
|
||||
PLUGIN_INFO = {
|
||||
"name": "XEP 0096 Plugin",
|
||||
"import_name": "XEP_0096",
|
||||
|
|
@ -36,16 +49,28 @@ PLUGIN_INFO = {
|
|||
"description": """Implementation of SI File Transfert"""
|
||||
}
|
||||
|
||||
class XEP_0096:
|
||||
class XEP_0096(XMPPHandler):
|
||||
implements(iwokkel.IDisco)
|
||||
|
||||
def __init__(self, host):
|
||||
info("Plugin XEP_0096 initialization")
|
||||
self.host = host
|
||||
self._waiting_for_approval = {}
|
||||
host.add_IQ_cb("http://jabber.org/protocol/si", self.xep_96)
|
||||
host.bridge.addMethod("sendFile", ".communication", in_sign='ss', out_sign='s', method=self.sendFile)
|
||||
|
||||
def connectionInitialized(self):
|
||||
self.xmlstream.addObserver(SI_REQUEST, self.xep_96)
|
||||
|
||||
|
||||
def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
|
||||
return [disco.DiscoFeature(NS_SI)]
|
||||
|
||||
def getDiscoItems(self, requestor, target, nodeIdentifier=''):
|
||||
return []
|
||||
|
||||
def xep_96(self, IQ):
|
||||
info ("XEP-0096 management")
|
||||
IQ.handled=True
|
||||
SI_elem = IQ.firstChildElement()
|
||||
debug(SI_elem.toXml())
|
||||
filename = ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue