pub fn send_image(&self, img: Arc<Image>) {
        let (client, storage, devices) =
            (self.inner.clone(), self.storage.clone(), self.devices.clone());

        let call_closure = Box::new(move |c: &HyperClient| {
            let enc_data = future_try_box!(utils::encrypt(img.data()));
            let img_size = img.data().len();
            let img_meta = img.metadata();
            let req_data = AssetUploadRequest {
                public: false,
                retention: "volatile",
            };

            let f = client.upload_asset(c, req_data, &enc_data.data, img_meta.format.into());
            let (c, client, storage, devices) =
                (c.clone(), client.clone(), storage.clone(), devices.clone());

            let f = f.and_then(move |asset_data| {
                let mut message = GenericMessage::new();
                let uuid = utils::uuid_v1();
                message.set_message_id(uuid.to_string());
                let mut asset = Asset::new();
                let mut original = Asset_Original::new();
                original.set_mime_type(img_meta.format.mime());
                original.set_size(img_size as u64);
                let mut meta = Asset_ImageMetaData::new();
                meta.set_width(img_meta.width as i32);
                meta.set_height(img_meta.height as i32);
                original.set_image(meta);
                asset.set_original(original);
                let mut upload_data = Asset_RemoteData::new();
                upload_data.set_otr_key(enc_data.key);
                upload_data.set_sha256(enc_data.hash);
                upload_data.set_asset_id(asset_data.key);
                upload_data.set_asset_token(asset_data.token);
                asset.set_uploaded(upload_data);
                message.set_asset(asset);
                client.send_encrypted_message(&c, &message, storage.clone(), devices.clone())
            });

            Box::new(f)
        });

        self.event_loop_sender.clone().send(call_closure).wait().map_err(|e| {
            error!("Cannot queue user image in event loop: {}", e);
        }).ok();
    }
/// Send an user image to the associated conversation. Use the exported
/// `Image` to open an image (from path, reader, or buffer).
Send an user image to the associated conversation. Use the exported
`Image` to open an image (from path, reader, or buffer).
Send an user image to the associated conversation . Use the exported ` Image ` to open an image ( from path reader or buffer ) .
pub fn send_image(&self, img: Arc<Image>) {
        let (client, storage, devices) =
            (self.inner.clone(), self.storage.clone(), self.devices.clone());
        let call_closure = Box::new(move |c: &HyperClient| {
            let enc_data = future_try_box!(utils::encrypt(img.data()));
            let img_size = img.data().len();
            let img_meta = img.metadata();
            let req_data = AssetUploadRequest {
                public: false,
                retention: "volatile",
            };
            let f = client.upload_asset(c, req_data, &enc_data.data, img_meta.format.into());
            let (c, client, storage, devices) =
                (c.clone(), client.clone(), storage.clone(), devices.clone());
            let f = f.and_then(move |asset_data| {
                let mut message = GenericMessage::new();
                let uuid = utils::uuid_v1();
                message.set_message_id(uuid.to_string());
                let mut asset = Asset::new();
                let mut original = Asset_Original::new();
                original.set_mime_type(img_meta.format.mime());
                original.set_size(img_size as u64);
                let mut meta = Asset_ImageMetaData::new();
                meta.set_width(img_meta.width as i32);
                meta.set_height(img_meta.height as i32);
                original.set_image(meta);
                asset.set_original(original);
                let mut upload_data = Asset_RemoteData::new();
                upload_data.set_otr_key(enc_data.key);
                upload_data.set_sha256(enc_data.hash);
                upload_data.set_asset_id(asset_data.key);
                upload_data.set_asset_token(asset_data.token);
                asset.set_uploaded(upload_data);
                message.set_asset(asset);
                client.send_encrypted_message(&c, &message, storage.clone(), devices.clone())
            });
            Box::new(f)
        });
        self.event_loop_sender.clone().send(call_closure).wait().map_err(|e| {
            error!("Cannot queue user image in event loop: {}", e);
        }).ok();
    }
pub fn send_image ( & self , img : Arc < Image > ) { let ( client , storage , devices ) = ( self . inner . clone ( ) , self . storage . clone ( ) , self . devices . clone ( ) ) ; let call_closure = Box :: new ( move | c : & HyperClient | { let enc_data = future_try_box ! ( utils encrypt ( img data ( ) ) ) ; let img_size = img . data ( ) . len ( ) ; let img_meta = img . metadata ( ) ; let req_data = AssetUploadRequest { public : false , retention : " " , } ; let f = client . upload_asset ( c , req_data , & enc_data . data , img_meta . format . into ( ) ) ; let ( c , client , storage , devices ) = ( c . clone ( ) , client . clone ( ) , storage . clone ( ) , devices . clone ( ) ) ; let f = f . and_then ( move | asset_data | { let mut message = GenericMessage :: new ( ) ; let uuid = utils :: uuid_v1 ( ) ; message . set_message_id ( uuid . to_string ( ) ) ; let mut asset = Asset :: new ( ) ; let mut original = Asset_Original :: new ( ) ; original . set_mime_type ( img_meta . format . mime ( ) ) ; original . set_size ( img_size as u64 ) ; let mut meta = Asset_ImageMetaData :: new ( ) ; meta . set_width ( img_meta . width as i32 ) ; meta . set_height ( img_meta . height as i32 ) ; original . set_image ( meta ) ; asset . set_original ( original ) ; let mut upload_data = Asset_RemoteData :: new ( ) ; upload_data . set_otr_key ( enc_data . key ) ; upload_data . set_sha256 ( enc_data . hash ) ; upload_data . set_asset_id ( asset_data . key ) ; upload_data . set_asset_token ( asset_data . token ) ; asset . set_uploaded ( upload_data ) ; message . set_asset ( asset ) ; client . send_encrypted_message ( & c , & message , storage . clone ( ) , devices . clone ( ) ) } ) ; Box :: new ( f ) } ) ; self . event_loop_sender . clone ( ) . send ( call_closure ) . wait ( ) . map_err ( | e | { error ! ( " " e ) ; } ) . ok ( ) ; }
Send an user image to the associated conversation.
Send an user image to the associated conversation .
&self
img
Arc<Image>