Mercurial > libervia-backend
comparison plugins/plugin_xep_0096.py @ 15:218ec9984fa5
wokkel integration part III + memory saved again
- disco handler (plugins handled)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 31 Oct 2009 00:18:35 +0100 |
parents | 4b05308d45f9 |
children | f2a745ca0fbc |
comparison
equal
deleted
inserted
replaced
14:a62d7d453f22 | 15:218ec9984fa5 |
---|---|
25 from twisted.words.protocols.jabber import client, jid, xmlstream, error | 25 from twisted.words.protocols.jabber import client, jid, xmlstream, error |
26 import os.path | 26 import os.path |
27 from twisted.internet import reactor #FIXME best way ??? | 27 from twisted.internet import reactor #FIXME best way ??? |
28 import pdb | 28 import pdb |
29 | 29 |
30 from zope.interface import implements | |
31 | |
32 try: | |
33 from twisted.words.protocols.xmlstream import XMPPHandler | |
34 except ImportError: | |
35 from wokkel.subprotocols import XMPPHandler | |
36 | |
37 from wokkel import disco, iwokkel | |
38 | |
39 IQ_SET = '/iq[@type="set"]' | |
40 NS_SI = 'http://jabber.org/protocol/si' | |
41 SI_REQUEST = IQ_SET + '/si[@xmlns="' + NS_SI + '"]' | |
42 | |
30 PLUGIN_INFO = { | 43 PLUGIN_INFO = { |
31 "name": "XEP 0096 Plugin", | 44 "name": "XEP 0096 Plugin", |
32 "import_name": "XEP_0096", | 45 "import_name": "XEP_0096", |
33 "type": "XEP", | 46 "type": "XEP", |
34 "dependencies": ["XEP_0065"], | 47 "dependencies": ["XEP_0065"], |
35 "main": "XEP_0096", | 48 "main": "XEP_0096", |
36 "description": """Implementation of SI File Transfert""" | 49 "description": """Implementation of SI File Transfert""" |
37 } | 50 } |
38 | 51 |
39 class XEP_0096: | 52 class XEP_0096(XMPPHandler): |
53 implements(iwokkel.IDisco) | |
54 | |
40 def __init__(self, host): | 55 def __init__(self, host): |
41 info("Plugin XEP_0096 initialization") | 56 info("Plugin XEP_0096 initialization") |
42 self.host = host | 57 self.host = host |
43 self._waiting_for_approval = {} | 58 self._waiting_for_approval = {} |
44 host.add_IQ_cb("http://jabber.org/protocol/si", self.xep_96) | |
45 host.bridge.addMethod("sendFile", ".communication", in_sign='ss', out_sign='s', method=self.sendFile) | 59 host.bridge.addMethod("sendFile", ".communication", in_sign='ss', out_sign='s', method=self.sendFile) |
46 | 60 |
61 def connectionInitialized(self): | |
62 self.xmlstream.addObserver(SI_REQUEST, self.xep_96) | |
63 | |
64 | |
65 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): | |
66 return [disco.DiscoFeature(NS_SI)] | |
67 | |
68 def getDiscoItems(self, requestor, target, nodeIdentifier=''): | |
69 return [] | |
70 | |
47 def xep_96(self, IQ): | 71 def xep_96(self, IQ): |
48 info ("XEP-0096 management") | 72 info ("XEP-0096 management") |
73 IQ.handled=True | |
49 SI_elem = IQ.firstChildElement() | 74 SI_elem = IQ.firstChildElement() |
50 debug(SI_elem.toXml()) | 75 debug(SI_elem.toXml()) |
51 filename = "" | 76 filename = "" |
52 file_size = "" | 77 file_size = "" |
53 for element in SI_elem.elements(): | 78 for element in SI_elem.elements(): |