* mu-msg-sexp: support signature checking, remove elvis code

This commit is contained in:
djcb 2012-09-01 20:04:24 +03:00
parent 9d6ef76f5f
commit e63ed13f5f
1 changed files with 12 additions and 27 deletions

View File

@ -22,12 +22,6 @@
#include "mu-msg.h" #include "mu-msg.h"
#include "mu-msg-iter.h" #include "mu-msg-iter.h"
#include "mu-msg-part.h" #include "mu-msg-part.h"
#ifdef BUILD_CRYPTO
#include "mu-msg-crypto.h"
#endif /*BUILD_CRYPTO*/
#include "mu-maildir.h" #include "mu-maildir.h"
static void static void
@ -252,35 +246,25 @@ struct _PartInfo {
}; };
typedef struct _PartInfo PartInfo; typedef struct _PartInfo PartInfo;
/* like the elvis operator,
* http://colinharrington.net/blog/2008/10/groovy-elvis-operator/
*/
static const char*
elvis (const char *s1, const char *s2)
{
return s1 ? s1 : s2;
}
static const char* static const char*
sig_verdict (MuMsgPart *mpart) sig_verdict (MuMsgPart *mpart)
{ {
#ifdef BUILD_CRYPTO MuMsgPartSigStatusReport *report;
MuMsgPartSigStatus sigstat;
switch (mpart->sig_status) { report = mpart->sig_status_report;
if (!report)
return "";
switch (report->verdict) {
case MU_MSG_PART_SIG_STATUS_GOOD: case MU_MSG_PART_SIG_STATUS_GOOD:
return ":signature good"; return ":signature verified";
case MU_MSG_PART_SIG_STATUS_BAD: case MU_MSG_PART_SIG_STATUS_BAD:
return ":signature bad"; return ":signature bad";
case MU_MSG_PART_SIG_STATUS_ERROR: case MU_MSG_PART_SIG_STATUS_ERROR:
return ":signature error"; /* ugly */ return ":signature unverified";
default: default:
return ""; return "";
} }
#else
return "";
#endif /*!BUILD_CRYPTO*/
} }
@ -332,10 +316,11 @@ each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
("%s(:index %d :name \"%s\" :mime-type \"%s/%s\"%s%s " ("%s(:index %d :name \"%s\" :mime-type \"%s/%s\"%s%s "
":type %s " ":type %s "
":attachment %s :size %i %s)", ":attachment %s :size %i %s)",
elvis (pinfo->parts, ""), part->index, pinfo->parts ? pinfo->parts: "",
part->index,
name ? name : "noname", name ? name : "noname",
elvis (part->type, "application"), part->type ? part->type : "application",
elvis (part->subtype, "octet-stream"), part->subtype ? part->subtype : "octet-stream",
tmpfile ? " :temp" : "", tmpfile ? tmpfile : "", tmpfile ? " :temp" : "", tmpfile ? tmpfile : "",
parttype, parttype,
mu_msg_part_maybe_attachment (part) ? "t" : "nil", mu_msg_part_maybe_attachment (part) ? "t" : "nil",