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