Fix libgpgme segfault error and re-enable gpg

Closes #255
async-cursors
Manos Pitsidianakis 2023-07-13 16:51:37 +03:00
parent 5b5869a2ec
commit 6086a3789d
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
3 changed files with 9 additions and 20 deletions

View File

@ -19,9 +19,6 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>. * along with meli. If not, see <http://www.gnu.org/licenses/>.
*/ */
//FIXME
#![allow(unused_imports, unused_variables)]
use std::{future::Future, pin::Pin}; use std::{future::Future, pin::Pin};
use melib::{ use melib::{
@ -31,28 +28,23 @@ use melib::{
}, },
error::*, error::*,
gpgme::*, gpgme::*,
log,
parser::BytesExt, parser::BytesExt,
}; };
pub async fn decrypt(raw: Vec<u8>) -> Result<(melib_pgp::DecryptionMetadata, Vec<u8>)> { pub async fn decrypt(raw: Vec<u8>) -> Result<(melib_pgp::DecryptionMetadata, Vec<u8>)> {
Err("libgpgme functions are temporarily disabled due to an unsolved bug <https://git.meli.delivery/meli/meli/issues/176>.".into())
/*
let mut ctx = Context::new()?; let mut ctx = Context::new()?;
let cipher = ctx.new_data_mem(&raw)?; let cipher = ctx.new_data_mem(&raw)?;
ctx.decrypt(cipher)?.await ctx.decrypt(cipher)?.await
*/
} }
pub async fn verify(a: Attachment) -> Result<()> { pub async fn verify(a: Attachment) -> Result<()> {
Err("libgpgme functions are temporarily disabled due to an unsolved bug <https://git.meli.delivery/meli/meli/issues/176>.".into())
/*
let (data, sig) = let (data, sig) =
melib_pgp::verify_signature(&a).chain_err_summary(|| "Could not verify signature.")?; melib_pgp::verify_signature(&a).chain_err_summary(|| "Could not verify signature.")?;
let mut ctx = Context::new()?; let mut ctx = Context::new()?;
let sig = ctx.new_data_mem(sig.body().trim())?; let sig = ctx.new_data_mem(sig.body().trim())?;
let data = ctx.new_data_mem(&data)?; let data = ctx.new_data_mem(&data)?;
ctx.verify(sig, data)?.await ctx.verify(sig, data)?.await
*/
} }
pub fn sign_filter( pub fn sign_filter(
@ -64,8 +56,6 @@ pub fn sign_filter(
Ok( Ok(
move |a: AttachmentBuilder| -> Pin<Box<dyn Future<Output = Result<AttachmentBuilder>>+Send>> { move |a: AttachmentBuilder| -> Pin<Box<dyn Future<Output = Result<AttachmentBuilder>>+Send>> {
Box::pin(async move { Box::pin(async move {
Err("libgpgme functions are temporarily disabled due to an unsolved bug <https://git.meli.delivery/meli/meli/issues/176>.".into())
/*
let a: Attachment = a.into(); let a: Attachment = a.into();
let mut ctx = Context::new()?; let mut ctx = Context::new()?;
let data = ctx.new_data_mem(&melib_pgp::convert_attachment_to_rfc_spec( let data = ctx.new_data_mem(&melib_pgp::convert_attachment_to_rfc_spec(
@ -90,7 +80,6 @@ pub fn sign_filter(
vec![], vec![],
) )
.into()) .into())
*/
}) })
}, },
) )
@ -106,8 +95,6 @@ pub fn encrypt_filter(
Ok( Ok(
move |a: AttachmentBuilder| -> Pin<Box<dyn Future<Output = Result<AttachmentBuilder>>+Send>> { move |a: AttachmentBuilder| -> Pin<Box<dyn Future<Output = Result<AttachmentBuilder>>+Send>> {
Box::pin(async move { Box::pin(async move {
Err("libgpgme functions are temporarily disabled due to an unsolved bug <https://git.meli.delivery/meli/meli/issues/176>.".into())
/*
let a: Attachment = a.into(); let a: Attachment = a.into();
log::trace!("main attachment is {:?}", &a); log::trace!("main attachment is {:?}", &a);
let mut ctx = Context::new()?; let mut ctx = Context::new()?;
@ -140,7 +127,6 @@ pub fn encrypt_filter(
vec![], vec![],
) )
.into()) .into())
*/
}) })
}, },
) )

View File

@ -363,11 +363,14 @@ impl EnvelopeView {
(&self.force_charset).into(), (&self.force_charset).into(),
); );
let (attachment_paths, attachment_tree) = self.attachment_displays_to_tree(&display); let (attachment_paths, attachment_tree) = self.attachment_displays_to_tree(&display);
let body_text = Self::attachment_displays_to_text(&display, true);
self.display = display; self.display = display;
self.body_text = body_text;
self.attachment_tree = attachment_tree; self.attachment_tree = attachment_tree;
self.attachment_paths = attachment_paths; self.attachment_paths = attachment_paths;
self.regenerate_body_text();
}
pub fn regenerate_body_text(&mut self) {
self.body_text = Self::attachment_displays_to_text(&self.display, true);
} }
pub fn attachment_displays_to_text( pub fn attachment_displays_to_text(
@ -1768,11 +1771,12 @@ impl Component for EnvelopeView {
} }
if caught { if caught {
self.links.clear(); self.links.clear();
self.parse_attachments(); self.regenerate_body_text();
self.initialised = false;
self.set_dirty(true);
} }
self.active_jobs.remove(job_id); self.active_jobs.remove(job_id);
self.set_dirty(true);
} }
_ => {} _ => {}
} }

View File

@ -554,7 +554,6 @@ impl Context {
) )
.set_err_kind(ErrorKind::External)); .set_err_kind(ErrorKind::External));
} }
unsafe { call!(&ctx.lib, gpgme_free)(verify_result as *mut ::libc::c_void) };
} }
let io_state_lck = io_state.lock().unwrap(); let io_state_lck = io_state.lock().unwrap();
let ret = io_state_lck let ret = io_state_lck