* crypto: implement automagic decryption when so requested

(mainly by adding some smartness to various part_foreach functions, adding
  mu_msg_(get|set)_auto_decrypt to mark a message for auto-decryption)
This commit is contained in:
djcb
2012-07-27 18:04:17 +03:00
parent c88aea5285
commit 8432156765
6 changed files with 234 additions and 65 deletions

View File

@ -44,6 +44,9 @@ struct _MuMsgFile {
char _path [PATH_MAX + 1];
char _maildir [PATH_MAX + 1];
/* whether to attemp to automagically decrypt encrypted parts */
gboolean _auto_decrypt;
/* list where we push allocated strings so we can
* free them when the struct gets destroyed
*/
@ -97,15 +100,25 @@ gboolean mu_msg_part_mime_save_object (GMimeObject *obj, const char *fullpath,
* get the MIME part that's probably the body of the message (heuristic)
*
* @param self a MuMsg
* @param decrypt whether decryption should be attempted, if needed
* @param want_html whether it should be a html type of body
*
* @return the MIME part, or NULL in case of error.
*/
GMimePart* mu_msg_mime_get_body_part (GMimeMessage *msg, gboolean want_html);
GMimePart* mu_msg_mime_get_body_part (GMimeMessage *msg, gboolean decrypt,
gboolean want_html);
/**
* Like g_mime_message_foreach, but will recurse into encrypted parts
*
* @param msg
* @param decrypt whether to try to automatically decrypt
* @param func
* @param user_data
*/
void mu_mime_message_foreach (GMimeMessage *msg, gboolean decrypt,
GMimeObjectForeachFunc func, gpointer user_data);
#ifdef BUILD_CRYPTO
/**
@ -136,6 +149,18 @@ char* mu_msg_mime_decrypt (GMimeMultipartEncrypted *encpart,
MuMsgOptions opts, GError **err);
/**
* decrypt the given encrypted mime multipart
*
* @param enc encrypted part
* @param opts options
* @param err receives error data
*
* @return the decrypted part, or NULL in case of error
*/
GMimeObject* mu_msg_crypto_decrypt_part (GMimeMultipartEncrypted *enc, MuMsgOptions opts,
GError **err);
#endif /*BUILD_CRYPTO*/
G_END_DECLS