Mercurial > libervia-backend
comparison src/plugins/plugin_exp_pipe.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | 9902ec2d8d9b |
children | beaf6bec2fcd |
comparison
equal
deleted
inserted
replaced
586:6a718ede8be1 | 587:952322b1d490 |
---|---|
55 self.host.plugins["XEP-0095"].registerSIProfile(PROFILE_NAME, self.transferRequest) | 55 self.host.plugins["XEP-0095"].registerSIProfile(PROFILE_NAME, self.transferRequest) |
56 host.bridge.addMethod("pipeOut", ".plugin", in_sign='ssa{ss}s', out_sign='s', method=self.pipeOut) | 56 host.bridge.addMethod("pipeOut", ".plugin", in_sign='ssa{ss}s', out_sign='s', method=self.pipeOut) |
57 | 57 |
58 def profileConnected(self, profile): | 58 def profileConnected(self, profile): |
59 client = self.host.getClient(profile) | 59 client = self.host.getClient(profile) |
60 client._pipe_waiting_for_approval = {} #key = id, value = [transfer data, IdelayedCall Reactor timeout, | 60 client._pipe_waiting_for_approval = {} #key = id, value = [transfer data, IdelayedCall Reactor timeout, |
61 # current stream method, [failed stream methods], profile] | 61 # current stream method, [failed stream methods], profile] |
62 | 62 |
63 def _kill_id(self, approval_id, profile): | 63 def _kill_id(self, approval_id, profile): |
64 """Delete a waiting_for_approval id, called after timeout | 64 """Delete a waiting_for_approval id, called after timeout |
65 @param approval_id: id of _pipe_waiting_for_approval""" | 65 @param approval_id: id of _pipe_waiting_for_approval""" |
66 info(_("SI Pipe Transfer: TimeOut reached for id %s") % approval_id) | 66 info(_("SI Pipe Transfer: TimeOut reached for id %s") % approval_id) |
67 try: | 67 try: |
68 client = self.host.getClient(profile) | 68 client = self.host.getClient(profile) |
69 del client._pipe_waiting_for_approval[approval_id] | 69 del client._pipe_waiting_for_approval[approval_id] |
70 except KeyError: | 70 except KeyError: |
71 warning(_("kill id called on a non existant approval id")) | 71 warning(_("kill id called on a non existant approval id")) |
72 | 72 |
73 def transferRequest(self, iq_id, from_jid, si_id, si_mime_type, si_el, profile): | 73 def transferRequest(self, iq_id, from_jid, si_id, si_mime_type, si_el, profile): |
74 """Called when a pipe transfer is requested | 74 """Called when a pipe transfer is requested |
75 @param iq_id: id of the iq request | 75 @param iq_id: id of the iq request |
76 @param from_jid: jid of the sender | 76 @param from_jid: jid of the sender |
77 @param si_id: Stream Initiation session id | 77 @param si_id: Stream Initiation session id |
83 client = self.host.getClient(profile) | 83 client = self.host.getClient(profile) |
84 if not client: | 84 if not client: |
85 raise ProfileNotInCacheError | 85 raise ProfileNotInCacheError |
86 pipe_elts = filter(lambda elt: elt.name == 'pipe', si_el.elements()) | 86 pipe_elts = filter(lambda elt: elt.name == 'pipe', si_el.elements()) |
87 feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_el) | 87 feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_el) |
88 | 88 |
89 if not pipe_elts: | 89 if not pipe_elts: |
90 warning(_("No pipe element found")) | 90 warning(_("No pipe element found")) |
91 self.host.plugins["XEP-0095"].sendBadRequestError(iq_id, from_jid, profile) | 91 self.host.plugins["XEP-0095"].sendBadRequestError(iq_id, from_jid, profile) |
92 return | 92 return |
93 | 93 |
94 if feature_elts: | 94 if feature_elts: |
95 feature_el = feature_elts[0] | 95 feature_el = feature_elts[0] |
96 form = data_form.Form.fromElement(feature_el.firstChildElement()) | 96 form = data_form.Form.fromElement(feature_el.firstChildElement()) |
97 try: | 97 try: |
98 stream_method = self.host.plugins["XEP-0020"].negociate(feature_el, 'stream-method',self.managed_stream_m) | 98 stream_method = self.host.plugins["XEP-0020"].negociate(feature_el, 'stream-method',self.managed_stream_m) |
200 | 200 |
201 feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_elt) | 201 feature_elts = self.host.plugins["XEP-0020"].getFeatureElt(si_elt) |
202 if not feature_elts: | 202 if not feature_elts: |
203 warning(_("No feature element")) | 203 warning(_("No feature element")) |
204 return | 204 return |
205 | 205 |
206 choosed_options = self.host.plugins["XEP-0020"].getChoosedOptions(feature_elts[0]) | 206 choosed_options = self.host.plugins["XEP-0020"].getChoosedOptions(feature_elts[0]) |
207 try: | 207 try: |
208 stream_method = choosed_options["stream-method"] | 208 stream_method = choosed_options["stream-method"] |
209 except KeyError: | 209 except KeyError: |
210 warning(_("No stream method choosed")) | 210 warning(_("No stream method choosed")) |
234 profile = self.host.memory.getProfileName(profile_key) | 234 profile = self.host.memory.getProfileName(profile_key) |
235 if not profile: | 235 if not profile: |
236 warning(_("Trying to send a file from an unknown profile")) | 236 warning(_("Trying to send a file from an unknown profile")) |
237 return "" | 237 return "" |
238 feature_elt = self.host.plugins["XEP-0020"].proposeFeatures({'stream-method': self.managed_stream_m}) | 238 feature_elt = self.host.plugins["XEP-0020"].proposeFeatures({'stream-method': self.managed_stream_m}) |
239 | 239 |
240 pipe_transfer_elts = [] | 240 pipe_transfer_elts = [] |
241 | 241 |
242 pipe_elt = domish.Element((PROFILE, 'pipe')) | 242 pipe_elt = domish.Element((PROFILE, 'pipe')) |
243 pipe_transfer_elts.append(pipe_elt) | 243 pipe_transfer_elts.append(pipe_elt) |
244 | 244 |
245 sid, offer = self.host.plugins["XEP-0095"].proposeStream(jid.JID(to_jid), PROFILE, feature_elt, pipe_transfer_elts, profile_key = profile) | 245 sid, offer = self.host.plugins["XEP-0095"].proposeStream(jid.JID(to_jid), PROFILE, feature_elt, pipe_transfer_elts, profile_key = profile) |
246 offer.addCallback(self.pipeCb, filepath, sid, profile) | 246 offer.addCallback(self.pipeCb, filepath, sid, profile) |