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