src/message_api.h
author Volker Birk <vb@pep-project.org>
Tue, 05 May 2015 08:42:50 +0200
changeset 240 25e968e8e72b
parent 239 8b9080f5ff08
child 241 176b70529dc3
permissions -rw-r--r--
renaming
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@83
    34
//	    the ownership of the new message goes to the caller
vb@117
    35
//	    if src is unencrypted this function returns PEP_UNENCRYPTED and sets
vb@117
    36
//	    dst to NULL
vb@38
    37
vb@44
    38
DYNAMIC_API PEP_STATUS encrypt_message(
vb@37
    39
        PEP_SESSION session,
vb@113
    40
        message *src,
vb@37
    41
        stringlist_t *extra,
vb@38
    42
        message **dst,
vb@81
    43
        PEP_enc_format enc_format
vb@37
    44
    );
vb@37
    45
vb@39
    46
vb@39
    47
// decrypt_message() - decrypt message in memory
vb@39
    48
//
vb@39
    49
//  parameters:
vb@48
    50
//      session (in)        session handle
vb@48
    51
//      src (in)            message to decrypt
vb@113
    52
//      mime (in)           MIME encoding wanted
vb@83
    53
//      dst (out)           pointer to new decrypted message or NULL on failure
vb@39
    54
//
vb@39
    55
//  return value:
vb@39
    56
//      error status or PEP_STATUS_OK on success
vb@83
    57
//
vb@83
    58
//	caveat:
vb@83
    59
//	    the ownership of the new message goes to the caller
vb@39
    60
vb@44
    61
DYNAMIC_API PEP_STATUS decrypt_message(
vb@37
    62
        PEP_SESSION session,
vb@113
    63
        message *src,
vb@113
    64
        PEP_MIME_format mime,
vb@113
    65
        message **dst
vb@37
    66
    );
vb@37
    67
vb@189
    68
vb@232
    69
typedef enum _PEP_color {
vb@237
    70
    PEP_rating_undefined = 0,
vb@237
    71
    PEP_rating_unencrypted,
vb@238
    72
    PEP_rating_cannot_decrypt,
vb@237
    73
    PEP_rating_unreliable,
vb@237
    74
    PEP_rating_reliable,
vb@237
    75
    PEP_rating_yellow = PEP_rating_reliable,
vb@237
    76
    PEP_rating_trusted,
vb@237
    77
    PEP_rating_green = PEP_rating_trusted,
vb@237
    78
    PEP_rating_trusted_and_anonymized,
vb@237
    79
    PEP_rating_fully_anonymous,   
vb@189
    80
vb@237
    81
    PEP_rating_under_attack = -1,
vb@237
    82
    PEP_rating_red = PEP_rating_under_attack,
vb@237
    83
    PEP_rating_b0rken = -2
vb@232
    84
} PEP_color;
vb@189
    85
vb@240
    86
// message_color() - get color for a message
vb@189
    87
//
vb@189
    88
//  parameters:
vb@189
    89
//      session (in)        session handle
vb@189
    90
//      msg (in)            message to get the color for
vb@189
    91
//      color (out)         color for the message
vb@189
    92
//
vb@189
    93
//  return value:
vb@189
    94
//      error status or PEP_STATUS_OK on success
vb@190
    95
//
vb@190
    96
//  caveat:
vb@190
    97
//      msg->from must point to a valid pEp_identity
vb@189
    98
vb@240
    99
DYNAMIC_API PEP_STATUS message_color(
vb@189
   100
        PEP_SESSION session,
vb@190
   101
        message *msg,
vb@232
   102
        PEP_color *color
vb@189
   103
    );
vb@189
   104
vb@239
   105
vb@240
   106
// identity_color() - get color for a single identity
vb@239
   107
//
vb@239
   108
//  parameters:
vb@239
   109
//      session (in)        session handle
vb@239
   110
//      ident (in)          identity to get the color for
vb@239
   111
//      color (out)         color for the identity
vb@239
   112
//
vb@239
   113
//  return value:
vb@239
   114
//      error status or PEP_STATUS_OK on success
vb@239
   115
vb@240
   116
DYNAMIC_API PEP_STATUS identity_color(
vb@239
   117
        PEP_SESSION session,
vb@239
   118
        pEp_identity *ident,
vb@239
   119
        PEP_color *color
vb@239
   120
    );
vb@239
   121
vb@239
   122
vb@37
   123
#ifdef __cplusplus
vb@37
   124
}
vb@37
   125
#endif
vb@37
   126