even nicer ;-)
authorvb
Sun, 22 Feb 2015 13:49:19 +0100
changeset 64d393c205d201
parent 63 f5b2641f4ae7
child 65 b4b2f063a7c4
even nicer ;-)
src/message_api.c
     1.1 --- a/src/message_api.c	Sun Feb 22 13:40:25 2015 +0100
     1.2 +++ b/src/message_api.c	Sun Feb 22 13:49:19 2015 +0100
     1.3 @@ -106,12 +106,12 @@
     1.4          char *ptext;
     1.5          char *ctext = NULL;
     1.6          size_t csize = 0;
     1.7 -        msg->enc_format = PEP_enc_pieces;
     1.8  
     1.9          switch (format) {
    1.10          case PEP_enc_MIME_multipart: {
    1.11              char *resulttext = NULL;
    1.12              bool free_ptext = false;
    1.13 +
    1.14              msg->enc_format = PEP_enc_MIME_multipart;
    1.15  
    1.16              if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
    1.17 @@ -123,11 +123,6 @@
    1.18              else if (src->longmsg) {
    1.19                  ptext = src->longmsg;
    1.20              }
    1.21 -            else {
    1.22 -                assert(0);
    1.23 -                status = PEP_ILLEGAL_VALUE;
    1.24 -                goto pep_error;
    1.25 -            }
    1.26  
    1.27              status = mime_encode_text(ptext, src->longmsg_formatted,
    1.28                      src->attachments, &resulttext);
    1.29 @@ -143,8 +138,7 @@
    1.30              free(resulttext);
    1.31              if (ctext) {
    1.32                  msg->longmsg = strdup(ctext);
    1.33 -                msg->shortmsg = strdup("pEp");
    1.34 -                if (!(msg->longmsg && msg->shortmsg))
    1.35 +                if (msg->longmsg == NULL)
    1.36                      goto enomem;
    1.37              }
    1.38              else {
    1.39 @@ -154,6 +148,8 @@
    1.40          break;
    1.41  
    1.42          case PEP_enc_pieces:
    1.43 +            msg->enc_format = PEP_enc_pieces;
    1.44 +
    1.45              if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
    1.46                  ptext = combine_short_and_long(src);
    1.47                  if (ptext == NULL)
    1.48 @@ -164,8 +160,7 @@
    1.49                  free(ptext);
    1.50                  if (ctext) {
    1.51                      msg->longmsg = strdup(ctext);
    1.52 -                    msg->shortmsg = strdup("pEp");
    1.53 -                    if (!(msg->longmsg && msg->shortmsg))
    1.54 +                    if (msg->longmsg == NULL)
    1.55                          goto enomem;
    1.56                  }
    1.57                  else {
    1.58 @@ -178,8 +173,7 @@
    1.59                          &ctext, &csize);
    1.60                  if (ctext) {
    1.61                      msg->longmsg = strdup(ctext);
    1.62 -                    msg->shortmsg = strdup("pEp");
    1.63 -                    if (!(msg->longmsg && msg->shortmsg))
    1.64 +                    if (msg->longmsg == NULL)
    1.65                          goto enomem;
    1.66                  }
    1.67                  else {
    1.68 @@ -239,6 +233,9 @@
    1.69  
    1.70      free_stringlist(keys);
    1.71  
    1.72 +    if (msg->shortmsg == NULL)
    1.73 +        msg->shortmsg = strdup("pEp");
    1.74 +
    1.75      *dst = msg;
    1.76      return PEP_STATUS_OK;
    1.77