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
     1.1 --- a/src/message_api.c	Wed May 06 13:00:38 2015 +0200
     1.2 +++ b/src/message_api.c	Wed May 06 13:46:08 2015 +0200
     1.3 @@ -105,6 +105,22 @@
     1.4          msg->attachments = bl;
     1.5  }
     1.6  
     1.7 +void determine_encryption_format(message *msg)
     1.8 +{
     1.9 +    assert(msg);
    1.10 +
    1.11 +    if (msg->enc_format != PEP_enc_none)
    1.12 +        return;
    1.13 +
    1.14 +    if (is_PGP_message_text(msg->longmsg))
    1.15 +        msg->enc_format = PEP_enc_pieces;
    1.16 +    else if (msg->attachments && msg->attachments->next &&
    1.17 +            is_mime_type(msg->attachments, "multipart/encrypted") &&
    1.18 +            is_PGP_message_text(msg->attachments->next->data)
    1.19 +        )
    1.20 +        msg->enc_format = PEP_enc_PGP_MIME;
    1.21 +}
    1.22 +
    1.23  static char * combine_short_and_long(const char *shortmsg, const char *longmsg)
    1.24  {
    1.25      char * ptext;
    1.26 @@ -344,6 +360,7 @@
    1.27  
    1.28      *dst = NULL;
    1.29  
    1.30 +    determine_encryption_format(src);
    1.31      import_attached_keys(session, src);
    1.32  
    1.33      if (src->enc_format >= PEP_enc_pieces) {
    1.34 @@ -673,6 +690,7 @@
    1.35  
    1.36      *dst = NULL;
    1.37   
    1.38 +    determine_encryption_format(src);
    1.39      import_attached_keys(session, src);
    1.40  
    1.41      if (src->mime == PEP_MIME_fields_omitted || src->mime == PEP_MIME) {