intermittent commit to stow changes ENGINE-40
authorKrista Grothoff <krista@pep-project.org>
Wed, 10 Aug 2016 12:53:40 +0200
branchENGINE-40
changeset 994808f6fc6c5e5
parent 992 949450dab40d
child 995 6d8b1c28c9a5
intermittent commit to stow changes
src/message_api.c
src/message_api.h
     1.1 --- a/src/message_api.c	Mon Aug 08 12:08:42 2016 +0200
     1.2 +++ b/src/message_api.c	Wed Aug 10 12:53:40 2016 +0200
     1.3 @@ -1239,18 +1239,6 @@
     1.4  
     1.5      *dst = NULL;
     1.6  
     1.7 -//     status = myself(session, src->from);
     1.8 -//     if (status != PEP_STATUS_OK)
     1.9 -//         goto pep_error;
    1.10 -
    1.11 -    char* target_fpr = target_id->fpr;
    1.12 -    if (!target_fpr)
    1.13 -        return PEP_KEY_NOT_FOUND; // FIXME: Error condition
    1.14 -        
    1.15 -    keys = new_stringlist(target_fpr); // ???
    1.16 -
    1.17 -    bool dest_keys_found = true;
    1.18 -    PEP_comm_type max_comm_type = PEP_ct_pEp;
    1.19      
    1.20      PEP_STATUS _status = update_identity(session, target_id);
    1.21      if (_status != PEP_STATUS_OK) {
    1.22 @@ -1258,15 +1246,17 @@
    1.23          goto pep_error;
    1.24      }
    1.25  
    1.26 -    max_comm_type = _get_comm_type(session, max_comm_type,
    1.27 -                                        target_id);
    1.28 +    char* target_fpr = target_id->fpr;
    1.29 +    if (!target_fpr)
    1.30 +        return PEP_KEY_NOT_FOUND; // FIXME: Error condition
    1.31 +        
    1.32 +    keys = new_stringlist(target_fpr);
    1.33  
    1.34 +    
    1.35      msg = clone_to_empty_message(src);
    1.36      if (msg == NULL)
    1.37          goto enomem;
    1.38  
    1.39 -//        attach_own_key(session, src);
    1.40 -
    1.41      switch (enc_format) {
    1.42          case PEP_enc_PGP_MIME:
    1.43          case PEP_enc_PEP: // BUG: should be implemented extra
    1.44 @@ -1293,15 +1283,12 @@
    1.45      if (status != PEP_STATUS_OK)
    1.46          goto pep_error;
    1.47  
    1.48 -//     if (msg && msg->shortmsg == NULL) {
    1.49 -//         msg->shortmsg = strdup("pEp");
    1.50 -//         assert(msg->shortmsg);
    1.51 -//         if (msg->shortmsg == NULL)
    1.52 -//             goto enomem;
    1.53 -//     }
    1.54 -// 
    1.55 -//     if (msg)
    1.56 -//         decorate_message(msg, PEP_rating_undefined, NULL);
    1.57 +     if (msg && msg->shortmsg == NULL) {
    1.58 +         msg->shortmsg = strdup("pEp");
    1.59 +         assert(msg->shortmsg);
    1.60 +         if (msg->shortmsg == NULL)
    1.61 +             goto enomem;
    1.62 +     }
    1.63  
    1.64      *dst = msg;
    1.65      return status;
     2.1 --- a/src/message_api.h	Mon Aug 08 12:08:42 2016 +0200
     2.2 +++ b/src/message_api.h	Wed Aug 10 12:53:40 2016 +0200
     2.3 @@ -47,6 +47,39 @@
     2.4          PEP_enc_format enc_format
     2.5      );
     2.6  
     2.7 +// encrypt_message_for_identity() - encrypt message for one particular identity in memory
     2.8 +//                     (to be used, for example, to save message drafts
     2.9 +//                      encrypted with owner ID)
    2.10 +//
    2.11 +//  parameters:
    2.12 +//      session (in)        session handle
    2.13 +//      target_id (in)      single identity this message should be encrypted for
    2.14 +//      src (in)            message to encrypt
    2.15 +//      dst (out)           pointer to new encrypted message or NULL on failure
    2.16 +//      enc_format (in)     encrypted format
    2.17 +//
    2.18 +//  return value:       (FIXME: This may not be correct or complete)
    2.19 +//      PEP_STATUS_OK                   on success
    2.20 +//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
    2.21 +//		                                could not be found
    2.22 +//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    2.23 +//		                                an ambiguous name
    2.24 +//		PEP_GET_KEY_FAILED		        cannot retrieve key
    2.25 +//
    2.26 +//	caveat:
    2.27 +//	    the ownership of src remains with the caller
    2.28 +//      the ownership of target_id remains w/ caller            
    2.29 +//	    the ownership of dst goes to the caller
    2.30 +//      message is NOT encrypted for any recipients or sender identities other than
    2.31 +//          whichever identity is in target_id
    2.32 +
    2.33 +DYNAMIC_API PEP_STATUS encrypt_message_for_identity(
    2.34 +        PEP_SESSION session,
    2.35 +        pEp_identity* target_id,
    2.36 +        message *src,
    2.37 +        message **dst,
    2.38 +        PEP_enc_format enc_format
    2.39 +    );
    2.40  
    2.41  typedef enum _PEP_color {
    2.42      PEP_rating_undefined = 0,