comparison src/plugins/plugin_xep_0234.py @ 1557:22f0307864b4

plugin XEP-0234: "senders" handling
author Goffi <goffi@goffi.org>
date Mon, 02 Nov 2015 22:02:41 +0100
parents cbfbe028d099
children ec3848916ee8
comparison
equal deleted inserted replaced
1556:cbfbe028d099 1557:22f0307864b4
72 return self.fileJingleSend(jid.JID(to_jid), filepath, name or None, file_desc or None, profile) 72 return self.fileJingleSend(jid.JID(to_jid), filepath, name or None, file_desc or None, profile)
73 73
74 def fileJingleSend(self, to_jid, filepath, name=None, file_desc=None, profile=C.PROF_KEY_NONE): 74 def fileJingleSend(self, to_jid, filepath, name=None, file_desc=None, profile=C.PROF_KEY_NONE):
75 self._j.initiate(to_jid, 75 self._j.initiate(to_jid,
76 [{'app_ns': NS_JINGLE_FT, 76 [{'app_ns': NS_JINGLE_FT,
77 'senders': self._j.ROLE_INITIATOR,
77 'app_kwargs': {'filepath': filepath, 78 'app_kwargs': {'filepath': filepath,
78 'name': name, 79 'name': name,
79 'file_desc': file_desc}, 80 'file_desc': file_desc},
80 }], 81 }],
81 profile=profile) 82 profile=profile)
163 return desc_elt 164 return desc_elt
164 165
165 def jingleRequestConfirmation(self, action, session, content_name, desc_elt, profile): 166 def jingleRequestConfirmation(self, action, session, content_name, desc_elt, profile):
166 """This method request confirmation for a jingle session""" 167 """This method request confirmation for a jingle session"""
167 content_data = session['contents'][content_name] 168 content_data = session['contents'][content_name]
169 if content_data['senders'] not in (self._j.ROLE_INITIATOR, self._j.ROLE_RESPONDER):
170 log.warning(u"Bad sender, assuming initiator")
171 content_data['senders'] = self._j.ROLE_INITIATOR
168 # first we grab file informations 172 # first we grab file informations
169 try: 173 try:
170 file_elt = desc_elt.elements(NS_JINGLE_FT, 'file').next() 174 file_elt = desc_elt.elements(NS_JINGLE_FT, 'file').next()
171 except StopIteration: 175 except StopIteration:
172 raise failure.Failure(exceptions.DataError) 176 raise failure.Failure(exceptions.DataError)