std::string CryptoChromeAPI::encrypt_sign(std::string recipient, std::string clear_txt)
{
	stlplus::subprocess p;

	stlplus::arg_vector args;
	args += "--quiet";
	args += "--no-tty";
	args += "--encrypt";
	args += "--sign";
	args += "--always-trust"; // TODO: remove this.
	args += "--armor";
	args += "--logger-fd";
	args += "1";
	args += "--recipient";
	args += recipient;

	p.spawn(get_gpg(), args, true, true, false);
	p.write_stdin(clear_txt);
	p.close_stdin();

	std::string output;
	p.read_stdout(output);

	return output;
}
static GMimeCryptoContext*
get_gpg_crypto_context (MuMsgOptions opts, GError **err)
{
	GMimeCryptoContext	*cctx;
	char			*gpg;

	cctx  = NULL;
	if (!(gpg   = get_gpg (err)))
		return NULL;

	cctx = g_mime_gpg_context_new (
		(GMimePasswordRequestFunc)password_requester, gpg);
	g_free (gpg);

	if (!cctx) {
		mu_util_g_set_error (err, MU_ERROR,
				     "failed to get GPG crypto context");
		return NULL;
	}

	/* always try to use the agent */
	g_mime_gpg_context_set_use_agent (GMIME_GPG_CONTEXT(cctx), TRUE);
 	g_mime_gpg_context_set_auto_key_retrieve
		(GMIME_GPG_CONTEXT(cctx),
		 opts & MU_MSG_OPTION_AUTO_RETRIEVE ? TRUE:FALSE);

	return cctx;
}
// Configuration
std::string CryptoChromeAPI::gpg_version()
{
	stlplus::subprocess p;

	stlplus::arg_vector args("--version");

	p.spawn(get_gpg(), args, false, true, false);

	std::string output;
	p.read_stdout(output);
    
    return output;
}
std::string CryptoChromeAPI::clearsign(std::string clear_txt)
{
	stlplus::subprocess p;

	stlplus::arg_vector args;
	args += "--quiet";
	args += "--no-tty";
	args += "--clearsign";
	args += "--armor";
	args += "--logger-fd";
	args += "1";

	p.spawn(get_gpg(), args, true, true, false);
	p.write_stdin(clear_txt);
	p.close_stdin();

	std::string output;
	p.read_stdout(output);

	return output;
}
// Text Processing
std::string CryptoChromeAPI::decrypt(std::string crypt_txt)
{
	stlplus::subprocess p;

	stlplus::arg_vector args;
	args += "--quiet";
	args += "--no-tty";
	args += "--decrypt";
	args += "--use-agent";
	args += "--logger-fd";
	args += "1";

	p.spawn(get_gpg(), args, true, true, false);
	p.write_stdin(crypt_txt);
	p.close_stdin();

	std::string output;
	p.read_stdout(output);

	return output;
}