src/message_api.h
author Volker Birk <vb@pep-project.org>
Thu, 07 May 2015 22:48:30 +0200
changeset 256 0232e3d7d77c
parent 251 dba7f09db1ed
child 258 8e8eec84418b
permissions -rw-r--r--
correcting results of decrypt_message()
vb@39
     1
#pragma once
vb@39
     2
vb@102
     3
#include "pEpEngine.h"
vb@102
     4
#include "keymanagement.h"
vb@101
     5
#include "message.h"
vb@101
     6
vb@37
     7
#ifdef __cplusplus
vb@37
     8
extern "C" {
vb@37
     9
#endif
vb@37
    10
vb@39
    11
vb@235
    12
void import_attached_keys(PEP_SESSION session, const message *msg);
vb@236
    13
void attach_own_key(PEP_SESSION session, message *msg);
vb@235
    14
vb@235
    15
vb@39
    16
// encrypt_message() - encrypt message in memory
vb@39
    17
//
vb@39
    18
//  parameters:
vb@48
    19
//      session (in)        session handle
vb@48
    20
//      src (in)            message to encrypt
vb@48
    21
//      extra (in)          extra keys for encryption
vb@83
    22
//      dst (out)           pointer to new encrypted message or NULL on failure
vb@84
    23
//      enc_format (in)     encrypted format
vb@39
    24
//
vb@39
    25
//  return value:
vb@48
    26
//      PEP_STATUS_OK                   on success
vb@48
    27
//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
vb@48
    28
//		                                could not be found
vb@48
    29
//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
vb@48
    30
//		                                an ambiguous name
vb@48
    31
//		PEP_GET_KEY_FAILED		        cannot retrieve key
vb@83
    32
//
vb@83
    33
//	caveat:
vb@251
    34
//	    the ownershop of src remains with the caller
vb@251
    35
//	    the ownership of dst goes to the caller
vb@117
    36
//	    if src is unencrypted this function returns PEP_UNENCRYPTED and sets
vb@117
    37
//	    dst to NULL
vb@38
    38
vb@44
    39
DYNAMIC_API PEP_STATUS encrypt_message(
vb@37
    40
        PEP_SESSION session,
vb@113
    41
        message *src,
vb@37
    42
        stringlist_t *extra,
vb@38
    43
        message **dst,
vb@81
    44
        PEP_enc_format enc_format
vb@37
    45
    );
vb@37
    46
vb@39
    47
vb@232
    48
typedef enum _PEP_color {
vb@237
    49
    PEP_rating_undefined = 0,
vb@256
    50
    PEP_rating_cannot_decrypt,
vb@237
    51
    PEP_rating_unencrypted,
vb@237
    52
    PEP_rating_unreliable,
vb@237
    53
    PEP_rating_reliable,
vb@237
    54
    PEP_rating_yellow = PEP_rating_reliable,
vb@237
    55
    PEP_rating_trusted,
vb@237
    56
    PEP_rating_green = PEP_rating_trusted,
vb@237
    57
    PEP_rating_trusted_and_anonymized,
vb@237
    58
    PEP_rating_fully_anonymous,   
vb@189
    59
vb@237
    60
    PEP_rating_under_attack = -1,
vb@237
    61
    PEP_rating_red = PEP_rating_under_attack,
vb@237
    62
    PEP_rating_b0rken = -2
vb@232
    63
} PEP_color;
vb@189
    64
vb@251
    65
// decrypt_message() - decrypt message in memory
vb@251
    66
//
vb@251
    67
//  parameters:
vb@251
    68
//      session (in)        session handle
vb@251
    69
//      src (in)            message to decrypt
vb@251
    70
//      mime (in)           MIME encoding wanted
vb@251
    71
//      dst (out)           pointer to new decrypted message or NULL on failure
vb@251
    72
//      keylist (out)       stringlist with keyids
vb@251
    73
//      color (out)         color for the message
vb@251
    74
//
vb@251
    75
//  return value:
vb@251
    76
//      error status or PEP_STATUS_OK on success
vb@251
    77
//
vb@251
    78
//	caveat:
vb@251
    79
//	    the ownership of src remains with the caller
vb@251
    80
//	    the ownership of dst goes to the caller
vb@251
    81
//	    the ownership of keylist goes to the caller
vb@251
    82
vb@251
    83
DYNAMIC_API PEP_STATUS decrypt_message(
vb@251
    84
        PEP_SESSION session,
vb@251
    85
        message *src,
vb@251
    86
        PEP_MIME_format mime,
vb@251
    87
        message **dst,
vb@251
    88
        stringlist_t **keylist,
vb@251
    89
        PEP_color *color
vb@251
    90
    );
vb@251
    91
vb@251
    92
vb@251
    93
// outgoing_message_color() - get color for an outgoing message
vb@189
    94
//
vb@189
    95
//  parameters:
vb@189
    96
//      session (in)        session handle
vb@189
    97
//      msg (in)            message to get the color for
vb@189
    98
//      color (out)         color for the message
vb@189
    99
//
vb@189
   100
//  return value:
vb@189
   101
//      error status or PEP_STATUS_OK on success
vb@190
   102
//
vb@190
   103
//  caveat:
vb@190
   104
//      msg->from must point to a valid pEp_identity
vb@251
   105
//      msg->dir must be PEP_dir_outgoing
vb@251
   106
//      the ownership of msg remains with the caller
vb@189
   107
vb@251
   108
DYNAMIC_API PEP_STATUS outgoing_message_color(
vb@189
   109
        PEP_SESSION session,
vb@190
   110
        message *msg,
vb@232
   111
        PEP_color *color
vb@189
   112
    );
vb@189
   113
vb@239
   114
vb@240
   115
// identity_color() - get color for a single identity
vb@239
   116
//
vb@239
   117
//  parameters:
vb@239
   118
//      session (in)        session handle
vb@239
   119
//      ident (in)          identity to get the color for
vb@239
   120
//      color (out)         color for the identity
vb@239
   121
//
vb@239
   122
//  return value:
vb@239
   123
//      error status or PEP_STATUS_OK on success
vb@251
   124
//
vb@251
   125
//  caveat:
vb@251
   126
//      the ownership of ident remains with the caller
vb@239
   127
vb@240
   128
DYNAMIC_API PEP_STATUS identity_color(
vb@239
   129
        PEP_SESSION session,
vb@239
   130
        pEp_identity *ident,
vb@239
   131
        PEP_color *color
vb@239
   132
    );
vb@239
   133
vb@239
   134
vb@37
   135
#ifdef __cplusplus
vb@37
   136
}
vb@37
   137
#endif
vb@37
   138