src/message_api.h
author Volker Birk <vb@pep-project.org>
Sun, 03 May 2015 16:40:28 +0200
changeset 235 8b7468ca8034
parent 232 3d44d9bb18e5
child 236 154a7077dbb7
permissions -rw-r--r--
import attached keys automatically in Message API
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@235
    13
vb@235
    14
vb@39
    15
// encrypt_message() - encrypt message in memory
vb@39
    16
//
vb@39
    17
//  parameters:
vb@48
    18
//      session (in)        session handle
vb@48
    19
//      src (in)            message to encrypt
vb@48
    20
//      extra (in)          extra keys for encryption
vb@83
    21
//      dst (out)           pointer to new encrypted message or NULL on failure
vb@84
    22
//      enc_format (in)     encrypted format
vb@39
    23
//
vb@39
    24
//  return value:
vb@48
    25
//      PEP_STATUS_OK                   on success
vb@48
    26
//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
vb@48
    27
//		                                could not be found
vb@48
    28
//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
vb@48
    29
//		                                an ambiguous name
vb@48
    30
//		PEP_GET_KEY_FAILED		        cannot retrieve key
vb@83
    31
//
vb@83
    32
//	caveat:
vb@83
    33
//	    the ownership of the new message goes to the caller
vb@117
    34
//	    if src is unencrypted this function returns PEP_UNENCRYPTED and sets
vb@117
    35
//	    dst to NULL
vb@38
    36
vb@44
    37
DYNAMIC_API PEP_STATUS encrypt_message(
vb@37
    38
        PEP_SESSION session,
vb@113
    39
        message *src,
vb@37
    40
        stringlist_t *extra,
vb@38
    41
        message **dst,
vb@81
    42
        PEP_enc_format enc_format
vb@37
    43
    );
vb@37
    44
vb@39
    45
vb@39
    46
// decrypt_message() - decrypt message in memory
vb@39
    47
//
vb@39
    48
//  parameters:
vb@48
    49
//      session (in)        session handle
vb@48
    50
//      src (in)            message to decrypt
vb@113
    51
//      mime (in)           MIME encoding wanted
vb@83
    52
//      dst (out)           pointer to new decrypted message or NULL on failure
vb@39
    53
//
vb@39
    54
//  return value:
vb@39
    55
//      error status or PEP_STATUS_OK on success
vb@83
    56
//
vb@83
    57
//	caveat:
vb@83
    58
//	    the ownership of the new message goes to the caller
vb@39
    59
vb@44
    60
DYNAMIC_API PEP_STATUS decrypt_message(
vb@37
    61
        PEP_SESSION session,
vb@113
    62
        message *src,
vb@113
    63
        PEP_MIME_format mime,
vb@113
    64
        message **dst
vb@37
    65
    );
vb@37
    66
vb@189
    67
vb@232
    68
typedef enum _PEP_color {
vb@232
    69
    PEP_undefined = 0,
vb@232
    70
    PEP_unencrypted,
vb@232
    71
    PEP_unreliable,
vb@232
    72
    PEP_reliable,
vb@232
    73
    PEP_yellow = PEP_reliable,
vb@232
    74
    PEP_trusted,
vb@232
    75
    PEP_green = PEP_trusted,
vb@232
    76
    PEP_trusted_and_anonymized,
vb@232
    77
    PEP_fully_anonymous,   
vb@189
    78
vb@232
    79
    PEP_under_attack = -1,
vb@232
    80
    PEP_red = PEP_under_attack,
vb@232
    81
    PEP_b0rken = -2
vb@232
    82
} PEP_color;
vb@189
    83
vb@194
    84
// get_message_color() - get color for a message
vb@189
    85
//
vb@189
    86
//  parameters:
vb@189
    87
//      session (in)        session handle
vb@189
    88
//      msg (in)            message to get the color for
vb@189
    89
//      color (out)         color for the message
vb@189
    90
//
vb@189
    91
//  return value:
vb@189
    92
//      error status or PEP_STATUS_OK on success
vb@190
    93
//
vb@190
    94
//  caveat:
vb@190
    95
//      msg->from must point to a valid pEp_identity
vb@189
    96
vb@194
    97
DYNAMIC_API PEP_STATUS get_message_color(
vb@189
    98
        PEP_SESSION session,
vb@190
    99
        message *msg,
vb@232
   100
        PEP_color *color
vb@189
   101
    );
vb@189
   102
vb@37
   103
#ifdef __cplusplus
vb@37
   104
}
vb@37
   105
#endif
vb@37
   106