src/message.h
author Krista Grothoff <krista@pep-project.org>
Sat, 24 Sep 2016 18:09:18 +0200
branchENGINE-27
changeset 1185 4b01328f3cf2
parent 497 37a111f06c7f
child 1513 e7f7e42385b5
permissions -rw-r--r--
ENGINE-27: update_identity no longer pays attention to the input identity's fpr, but pulls one from elect_pubkey.
vb@99
     1
#pragma once
vb@99
     2
vb@99
     3
#include <time.h>
vb@106
     4
vb@99
     5
#include "pEpEngine.h"
vb@99
     6
#include "identity_list.h"
vb@99
     7
#include "bloblist.h"
vb@106
     8
#include "stringlist.h"
vb@99
     9
#include "stringpair.h"
vb@113
    10
#include "timestamp.h"
vb@99
    11
vb@99
    12
#ifdef __cplusplus
vb@99
    13
extern "C" {
vb@99
    14
#endif
vb@99
    15
vb@99
    16
vb@99
    17
typedef enum _PEP_text_format {
vb@99
    18
    PEP_text_format_plain = 0,
vb@99
    19
    PEP_text_format_html,
vb@99
    20
    PEP_text_format_other = 0xff
vb@99
    21
} PEP_text_format;
vb@99
    22
vb@99
    23
typedef enum _PEP_msg_direction {
vb@99
    24
    PEP_dir_incoming = 0,
vb@99
    25
    PEP_dir_outgoing
vb@99
    26
} PEP_msg_direction;
vb@99
    27
vb@99
    28
typedef enum _PEP_enc_format {
vb@113
    29
    PEP_enc_none = 0,                       // message is not encrypted
vb@112
    30
    PEP_enc_pieces,                         // inline PGP + PGP extensions
vb@113
    31
    PEP_enc_S_MIME,                         // RFC5751
vb@112
    32
    PEP_enc_PGP_MIME,                       // RFC3156
vb@99
    33
    PEP_enc_PEP                             // pEp encryption format
vb@99
    34
} PEP_enc_format;
vb@99
    35
vb@99
    36
struct _message_ref_list;
vb@99
    37
vb@99
    38
typedef struct _message {
vb@99
    39
    PEP_msg_direction dir;
vb@99
    40
    char *id;                               // UTF-8 string of message ID
vb@99
    41
    char *shortmsg;                         // UTF-8 string of short message
vb@99
    42
    char *longmsg;                          // UTF-8 string of long message
vb@99
    43
                                            // (plain)
vb@99
    44
    char *longmsg_formatted;                // UTF-8 string of long message
vb@99
    45
                                            // (formatted)
vb@99
    46
    bloblist_t *attachments;                // blobs with attachements
vb@497
    47
    char *rawmsg_ref;                       // reference to raw message data
vb@99
    48
    size_t rawmsg_size;                     // size of raw message data
vb@99
    49
    timestamp *sent;                        // when the message is sent
vb@99
    50
    timestamp *recv;                        // when the message is received
vb@99
    51
    pEp_identity *from;                     // whom the message is from
vb@99
    52
    identity_list *to;                      // whom the message is to
vb@99
    53
    pEp_identity *recv_by;                  // via which identity the message
vb@99
    54
                                            // is received
vb@99
    55
    identity_list *cc;                      // whom a CC is being sent
vb@99
    56
    identity_list *bcc;                     // whom a BCC is being sent
vb@99
    57
    identity_list *reply_to;                // where a reply should go to
vb@99
    58
    stringlist_t *in_reply_to;              // list of UTF-8 strings with
vb@351
    59
                                            // MessageIDs of refering messages
vb@99
    60
    struct _message *refering_msg_ref;      // reference to refering message
vb@99
    61
    stringlist_t *references;               // list of UTF-8 strings with references
vb@99
    62
    struct _message_ref_list *refered_by;   // list of references to messages being
vb@99
    63
                                            // refered
vb@99
    64
    stringlist_t *keywords;                 // list of UTF-8 strings with keywords
vb@99
    65
    char *comments;                         // UTF-8 string with comments
vb@99
    66
    stringpair_list_t *opt_fields;          // optional fields
vb@99
    67
    PEP_enc_format enc_format;              // format of encrypted data
vb@99
    68
} message;
vb@99
    69
vb@99
    70
typedef struct _message_ref_list {
vb@99
    71
    message *msg_ref;                       // reference to message
vb@99
    72
    struct _message_ref_list *next;
vb@99
    73
} message_ref_list;
vb@99
    74
vb@99
    75
vb@99
    76
// new_message() - allocate new message
vb@99
    77
//
vb@99
    78
//  parameters:
vb@99
    79
//      dir (in)        PEP_dir_incoming or PEP_dir_outgoing
vb@99
    80
//
vb@99
    81
//  return value:
vb@99
    82
//      pointer to new message or NULL if out of memory
vb@99
    83
vb@99
    84
DYNAMIC_API message *new_message(
vb@305
    85
        PEP_msg_direction dir
vb@99
    86
    );
vb@99
    87
vb@99
    88
vb@99
    89
// free_message() - free message struct
vb@99
    90
//
vb@99
    91
//  parameters:
vb@117
    92
//      msg (in)        message struct to free
vb@99
    93
//
roker@492
    94
//  NOTA BENE:
roker@492
    95
//      raw data (msg->rawmsg_ref) and referenced other messages (msg->refering_msg_ref)
roker@492
    96
//      aren't freed and remain in the ownership of the caller!
vb@99
    97
vb@117
    98
DYNAMIC_API void free_message(message *msg);
vb@99
    99
vb@99
   100
vb@99
   101
// message_dup - duplicate message (deep copy)
vb@99
   102
//
vb@99
   103
//  parameters:
vb@99
   104
//      msg (in)        message to duplicate
vb@99
   105
//
vb@99
   106
//  return value:
vb@99
   107
//      pointer to duplicate of message pointed by msg or NULL
roker@492
   108
//  NOTA BENE:
roker@492
   109
//      not owned pointees (msg->rawmsg_ref and msg->refering_msg_ref) are shared!
vb@99
   110
vb@99
   111
DYNAMIC_API message * message_dup(const message *msg);
vb@99
   112
vb@99
   113
// new_message_ref_list() - allocate new message reference list
vb@99
   114
//
vb@99
   115
//  parameters:
vb@99
   116
//      msg (in)        message to add a reference to or NULL
vb@99
   117
//
vb@99
   118
//  return value:
vb@99
   119
//      pointer to new message_ref_list or NULL if out of memory
vb@99
   120
vb@99
   121
DYNAMIC_API message_ref_list *new_message_ref_list(message *msg);
vb@99
   122
vb@99
   123
vb@99
   124
// free_message_ref_list() - free message reference list
vb@99
   125
//
vb@99
   126
//  parameters:
vb@99
   127
//      msg_list (in)   message_ref_list to free
vb@99
   128
vb@99
   129
DYNAMIC_API void free_message_ref_list(message_ref_list *msg_list);
vb@99
   130
vb@99
   131
vb@99
   132
// message_ref_list_dup() - duplicate message reference list
vb@99
   133
//
vb@99
   134
//  paramters:
vb@99
   135
//      src (in)        message_ref_list to duplicate
vb@99
   136
//
vb@99
   137
//  return value:
vb@99
   138
//      pointer to new message_ref_list or NULL if out of memory
vb@99
   139
vb@99
   140
DYNAMIC_API message_ref_list *message_ref_list_dup(
vb@99
   141
        const message_ref_list *src
vb@99
   142
    );
vb@99
   143
vb@99
   144
// message_ref_list_add() - add a reference to a message to a message reference
vb@99
   145
// list
vb@99
   146
//
vb@99
   147
//  parameters:
vb@99
   148
//      msg_list (in)   message_ref_list to add to
vb@99
   149
//      msg (in)        message to add a reference to
vb@99
   150
//
vb@99
   151
//  return value:
vb@99
   152
//      pointer to the last element of message_ref_list or NULL if out of
vb@99
   153
//      memory
vb@99
   154
vb@99
   155
DYNAMIC_API message_ref_list *message_ref_list_add(message_ref_list *msg_list,
vb@99
   156
        message *msg);
vb@99
   157
vb@99
   158
vb@99
   159
#ifdef __cplusplus
vb@99
   160
}
vb@99
   161
#endif
vb@99
   162