p≡p engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
6.0 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
3 years ago
7 years ago
8 years ago
8 years ago
  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #pragma once
  4. #include <time.h>
  5. #include "pEpEngine.h"
  6. #include "identity_list.h"
  7. #include "bloblist.h"
  8. #include "stringlist.h"
  9. #include "stringpair.h"
  10. #include "timestamp.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. typedef enum _PEP_text_format {
  15. PEP_text_format_plain = 0,
  16. PEP_text_format_html,
  17. PEP_text_format_other = 0xff
  18. } PEP_text_format;
  19. typedef enum _PEP_msg_direction {
  20. PEP_dir_incoming = 0,
  21. PEP_dir_outgoing
  22. } PEP_msg_direction;
  23. typedef enum _PEP_enc_format {
  24. PEP_enc_none = 0, // message is not encrypted
  25. PEP_enc_pieces, // inline PGP + PGP extensions
  26. PEP_enc_S_MIME, // RFC5751
  27. PEP_enc_PGP_MIME, // RFC3156
  28. PEP_enc_PEP, // pEp encryption format
  29. PEP_enc_PGP_MIME_Outlook1 // Message B0rken by Outlook type 1
  30. } PEP_enc_format;
  31. struct _message_ref_list;
  32. typedef struct _message {
  33. PEP_msg_direction dir;
  34. char *id; // UTF-8 string of message ID
  35. char *shortmsg; // UTF-8 string of short message
  36. char *longmsg; // UTF-8 string of long message
  37. // (plain)
  38. char *longmsg_formatted; // UTF-8 string of long message
  39. // (formatted)
  40. bloblist_t *attachments; // blobs with attachements
  41. char *rawmsg_ref; // reference to raw message data
  42. size_t rawmsg_size; // size of raw message data
  43. timestamp *sent; // when the message is sent
  44. timestamp *recv; // when the message is received
  45. pEp_identity *from; // whom the message is from
  46. identity_list *to; // whom the message is to
  47. pEp_identity *recv_by; // via which identity the message
  48. // is received
  49. identity_list *cc; // whom a CC is being sent
  50. identity_list *bcc; // whom a BCC is being sent
  51. identity_list *reply_to; // where a reply should go to
  52. stringlist_t *in_reply_to; // list of UTF-8 strings with
  53. // MessageIDs of refering messages
  54. struct _message *refering_msg_ref; // reference to refering message
  55. stringlist_t * references; // list of UTF-8 strings with references
  56. struct _message_ref_list *refered_by; // list of references to messages being
  57. // refered
  58. stringlist_t *keywords; // list of UTF-8 strings with keywords
  59. char *comments; // UTF-8 string with comments
  60. stringpair_list_t *opt_fields; // optional fields
  61. PEP_enc_format enc_format; // format of encrypted data
  62. } message;
  63. typedef struct _message_ref_list {
  64. message *msg_ref; // reference to message
  65. struct _message_ref_list *next;
  66. } message_ref_list;
  67. // new_message() - allocate new message
  68. //
  69. // parameters:
  70. // dir (in) PEP_dir_incoming or PEP_dir_outgoing
  71. //
  72. // return value:
  73. // pointer to new message or NULL if out of memory
  74. DYNAMIC_API message *new_message(
  75. PEP_msg_direction dir
  76. );
  77. // free_message() - free message struct
  78. //
  79. // parameters:
  80. // msg (in) message struct to free
  81. //
  82. // NOTA BENE:
  83. // raw data (msg->rawmsg_ref) and referenced other messages (msg->refering_msg_ref)
  84. // aren't freed and remain in the ownership of the caller!
  85. DYNAMIC_API void free_message(message *msg);
  86. // message_dup - duplicate message (deep copy)
  87. //
  88. // parameters:
  89. // msg (in) message to duplicate
  90. //
  91. // return value:
  92. // pointer to duplicate of message pointed by msg or NULL
  93. // NOTA BENE:
  94. // not owned pointees (msg->rawmsg_ref and msg->refering_msg_ref) are shared!
  95. DYNAMIC_API message * message_dup(const message *msg);
  96. // message_transfer - assign ownership of all fields of the src message to
  97. // the dst message object passed in. Free respective memory
  98. // in the dst message, and reinitialise and pointers in
  99. // the src message to NULL so that it can be freed properly
  100. // by its owner.
  101. // parameters:
  102. // dst (inout) message to clobber and reassign values to
  103. // src (inout) message whose values will be transfered to dst
  104. // NOTA BENE:
  105. // not owned pointees (msg->rawmsg_ref and msg->refering_msg_ref) are shared!
  106. // these are simply transferred.
  107. DYNAMIC_API void message_transfer(message* dst, message *src);
  108. // new_message_ref_list() - allocate new message reference list
  109. //
  110. // parameters:
  111. // msg (in) message to add a reference to or NULL
  112. //
  113. // return value:
  114. // pointer to new message_ref_list or NULL if out of memory
  115. DYNAMIC_API message_ref_list *new_message_ref_list(message *msg);
  116. // free_message_ref_list() - free message reference list
  117. //
  118. // parameters:
  119. // msg_list (in) message_ref_list to free
  120. DYNAMIC_API void free_message_ref_list(message_ref_list *msg_list);
  121. // message_ref_list_dup() - duplicate message reference list
  122. //
  123. // paramters:
  124. // src (in) message_ref_list to duplicate
  125. //
  126. // return value:
  127. // pointer to new message_ref_list or NULL if out of memory
  128. DYNAMIC_API message_ref_list *message_ref_list_dup(
  129. const message_ref_list *src
  130. );
  131. // message_ref_list_add() - add a reference to a message to a message reference
  132. // list
  133. //
  134. // parameters:
  135. // msg_list (in) message_ref_list to add to
  136. // msg (in) message to add a reference to
  137. //
  138. // return value:
  139. // pointer to the last element of message_ref_list or NULL if out of
  140. // memory
  141. DYNAMIC_API message_ref_list *message_ref_list_add(message_ref_list *msg_list,
  142. message *msg);
  143. #ifdef __cplusplus
  144. }
  145. #endif