src/message.h
author us@chu.huenfield.org
Tue, 25 Dec 2018 14:46:45 +0100
branchsync
changeset 3209 c15b4ca2b52a
parent 3136 56e8a45b4fa6
child 3327 e423895a97fa
child 3675 c724fa64eb56
child 3678 07aceb41d96e
permissions -rw-r--r--
Replace use of Sequoia's backend with a custom key store.

- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.

- This patch changes the Sequoia backend to use a local sqlite
database to store the public keys.
     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 // message_transfer - assign ownership of all fields of the src message to
   118 //                    the dst message object passed in. Free respective memory
   119 //                    in the dst message, and reinitialise and pointers in 
   120 //                    the src message to NULL so that it can be freed properly
   121 //                    by its owner.
   122 //  parameters:
   123 //      dst (inout)        message to clobber and reassign values to
   124 //      src (inout)        message whose values will be transfered to dst
   125 //  NOTA BENE:
   126 //      not owned pointees (msg->rawmsg_ref and msg->refering_msg_ref) are shared!
   127 //      these are simply transferred.
   128 DYNAMIC_API void message_transfer(message* dst, message *src);
   129 
   130 
   131 // new_message_ref_list() - allocate new message reference list
   132 //
   133 //  parameters:
   134 //      msg (in)        message to add a reference to or NULL
   135 //
   136 //  return value:
   137 //      pointer to new message_ref_list or NULL if out of memory
   138 
   139 DYNAMIC_API message_ref_list *new_message_ref_list(message *msg);
   140 
   141 
   142 // free_message_ref_list() - free message reference list
   143 //
   144 //  parameters:
   145 //      msg_list (in)   message_ref_list to free
   146 
   147 DYNAMIC_API void free_message_ref_list(message_ref_list *msg_list);
   148 
   149 
   150 // message_ref_list_dup() - duplicate message reference list
   151 //
   152 //  paramters:
   153 //      src (in)        message_ref_list to duplicate
   154 //
   155 //  return value:
   156 //      pointer to new message_ref_list or NULL if out of memory
   157 
   158 DYNAMIC_API message_ref_list *message_ref_list_dup(
   159         const message_ref_list *src
   160     );
   161 
   162 // message_ref_list_add() - add a reference to a message to a message reference
   163 // list
   164 //
   165 //  parameters:
   166 //      msg_list (in)   message_ref_list to add to
   167 //      msg (in)        message to add a reference to
   168 //
   169 //  return value:
   170 //      pointer to the last element of message_ref_list or NULL if out of
   171 //      memory
   172 
   173 DYNAMIC_API message_ref_list *message_ref_list_add(message_ref_list *msg_list,
   174         message *msg);
   175 
   176 
   177 #ifdef __cplusplus
   178 }
   179 #endif