determine encryption format
authorVolker Birk <vb@pep-project.org>
Wed, 06 May 2015 13:46:08 +0200
changeset 250ace6314d8e64
parent 249 053050183172
child 251 dba7f09db1ed
determine encryption format
db/trustwords.py
src/message_api.c
     2.1 --- a/src/message_api.c	Wed May 06 13:00:38 2015 +0200
     2.2 +++ b/src/message_api.c	Wed May 06 13:46:08 2015 +0200
     2.3 @@ -105,6 +105,22 @@
     2.4          msg->attachments = bl;
     2.5  }
     2.6  
     2.7 +void determine_encryption_format(message *msg)
     2.8 +{
     2.9 +    assert(msg);
    2.10 +
    2.11 +    if (msg->enc_format != PEP_enc_none)
    2.12 +        return;
    2.13 +
    2.14 +    if (is_PGP_message_text(msg->longmsg))
    2.15 +        msg->enc_format = PEP_enc_pieces;
    2.16 +    else if (msg->attachments && msg->attachments->next &&
    2.17 +            is_mime_type(msg->attachments, "multipart/encrypted") &&
    2.18 +            is_PGP_message_text(msg->attachments->next->data)
    2.19 +        )
    2.20 +        msg->enc_format = PEP_enc_PGP_MIME;
    2.21 +}
    2.22 +
    2.23  static char * combine_short_and_long(const char *shortmsg, const char *longmsg)
    2.24  {
    2.25      char * ptext;
    2.26 @@ -344,6 +360,7 @@
    2.27  
    2.28      *dst = NULL;
    2.29  
    2.30 +    determine_encryption_format(src);
    2.31      import_attached_keys(session, src);
    2.32  
    2.33      if (src->enc_format >= PEP_enc_pieces) {
    2.34 @@ -673,6 +690,7 @@
    2.35  
    2.36      *dst = NULL;
    2.37   
    2.38 +    determine_encryption_format(src);
    2.39      import_attached_keys(session, src);
    2.40  
    2.41      if (src->mime == PEP_MIME_fields_omitted || src->mime == PEP_MIME) {