comparison src/plugins/plugin_xep_0234.py @ 1618:0de5f210fe56

plugin XEP-0300: implemented hashing: - parseHashElt do what it says - calculateHashElt can calculate a whole hash in a non-blocking way - or getHasher can be used for progressive hashing - getBestPeerAlgo return the best available hashing algorithm of an entity
author Goffi <goffi@goffi.org>
date Tue, 17 Nov 2015 19:48:19 +0100
parents b144babc2658
children 4dd07d026214
comparison
equal deleted inserted replaced
1617:d05f9179fe22 1618:0de5f210fe56
56 self.host = host 56 self.host = host
57 self._j = host.plugins["XEP-0166"] # shortcut to access jingle 57 self._j = host.plugins["XEP-0166"] # shortcut to access jingle
58 self._j.registerApplication(NS_JINGLE_FT, self) 58 self._j.registerApplication(NS_JINGLE_FT, self)
59 self._f = host.plugins["FILE"] 59 self._f = host.plugins["FILE"]
60 self._f.register(NS_JINGLE_FT, self.fileJingleSend, priority = 10000, method_name=u"Jingle") 60 self._f.register(NS_JINGLE_FT, self.fileJingleSend, priority = 10000, method_name=u"Jingle")
61 self._hash = self.host.plugins["XEP-0300"]
61 host.bridge.addMethod("fileJingleSend", ".plugin", in_sign='sssss', out_sign='', method=self._fileJingleSend) 62 host.bridge.addMethod("fileJingleSend", ".plugin", in_sign='sssss', out_sign='', method=self._fileJingleSend)
62 63
63 def getHandler(self, profile): 64 def getHandler(self, profile):
64 return XEP_0234_handler() 65 return XEP_0234_handler()
65 66
114 desc_elt = domish.Element((NS_JINGLE_FT, 'description')) 115 desc_elt = domish.Element((NS_JINGLE_FT, 'description'))
115 file_elt = desc_elt.addElement("file") 116 file_elt = desc_elt.addElement("file")
116 for name in ('date', 'desc', 'media-type', 'name', 'size'): 117 for name in ('date', 'desc', 'media-type', 'name', 'size'):
117 file_elt.addElement(name, content=unicode(file_data[name])) 118 file_elt.addElement(name, content=unicode(file_data[name]))
118 file_elt.addElement("range") # TODO 119 file_elt.addElement("range") # TODO
119 file_elt.addChild(self.host.plugins["XEP-0300"].buidHash()) 120 file_elt.addChild(self._hash.buildHashElt())
120 return desc_elt 121 return desc_elt
121 122
122 def jingleRequestConfirmation(self, action, session, content_name, desc_elt, profile): 123 def jingleRequestConfirmation(self, action, session, content_name, desc_elt, profile):
123 """This method request confirmation for a jingle session""" 124 """This method request confirmation for a jingle session"""
124 content_data = session['contents'][content_name] 125 content_data = session['contents'][content_name]