def _sendMediaMessage(self, builder, success, error = None, progress = None): # axolotlIface = self.getLayerInterface(YowAxolotlLayer) # if axolotlIface: # axolotlIface.encryptMedia(builder) iq = RequestUploadIqProtocolEntity(builder.mediaType, filePath = builder.getFilepath(), encrypted = builder.isEncrypted()) successFn = lambda resultEntity, requestUploadEntity: self.__onRequestUploadSuccess(resultEntity, requestUploadEntity, builder, success, error, progress) errorFn = lambda errorEntity, requestUploadEntity: self.__onRequestUploadError(errorEntity, requestUploadEntity, error) self._sendIq(iq, successFn, errorFn)
def send_by_path(self, jid, path): """ Send a file by its absolute path. Creates a RequestUpload entity, that will verify if the media has already been uploaded. Then calls the _on_upload_result. """ entity = RequestUploadIqProtocolEntity(self.MEDIA_TYPE, filePath=path) success_callback = lambda upload_result, request_entity: self._on_upload_request_result( jid, path, upload_result, request_entity) err_callback = lambda error_result, request_entity: self._on_error(jid) self.interface_layer._sendIq(entity, success_callback, err_callback)
def send_by_path(self, jid, path, caption=None): """ Send a file by its absolute path. Creates a RequestUpload entity, that will verify if the media has already been uploaded. Then calls the _on_upload_result. """ self.jid = jid self.path = path entity = RequestUploadIqProtocolEntity(self.MEDIA_TYPE, filePath=self.path) self.interface_layer._sendIq(entity, self._on_upload_result, self._on_error)