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.

103 lines
2.5 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. #pragma once
  2. #include "pEpEngine.h"
  3. #include <time.h>
  4. #include <stdlib.h>
  5. // all functions are using POSIX struct tm
  6. typedef struct tm timestamp;
  7. typedef enum _PEP_transports {
  8. // auto transport chooses transport per message automatically
  9. PEP_trans_auto = 0,
  10. // PEP_trans_email,
  11. // PEP_trans_whatsapp,
  12. PEP_trans__count
  13. } PEP_transports;
  14. typedef struct _PEP_transport_t PEP_transport_t;
  15. typedef struct _identity_list {
  16. pEp_identity *ident;
  17. struct _identity_list *next;
  18. } identity_list;
  19. identity_list *new_identity_list(const pEp_identity *ident);
  20. identity_list *identity_list_dup(const identity_list *src);
  21. void free_identity_list(identity_list *id_list);
  22. identity_list *identity_list_add(identity_list *id_list, const pEp_identity *ident);
  23. typedef enum _msg_format {
  24. format_plain = 0,
  25. format_html
  26. } msg_format;
  27. typedef enum _msg_direction {
  28. dir_incoming = 0,
  29. dir_outgoing
  30. } msg_direction;
  31. struct _message_ref_list;
  32. typedef struct _message {
  33. msg_direction dir;
  34. char * id;
  35. size_t id_size;
  36. char * shortmsg;
  37. size_t shortmsg_size;
  38. char * longmsg;
  39. size_t longmsg_size;
  40. char * longmsg_formatted;
  41. size_t longmsg_formatted_size;
  42. msg_format format;
  43. char * rawmsg;
  44. size_t rawmsg_size;
  45. timestamp sent;
  46. timestamp recv;
  47. pEp_identity *from;
  48. identity_list *to;
  49. pEp_identity *recv_by;
  50. identity_list *cc;
  51. identity_list *bcc;
  52. char * refering_id;
  53. size_t refering_id_size;
  54. struct _message *refering_msg;
  55. struct _message_ref_list *refered_by;
  56. } message;
  57. typedef struct _message_ref_list {
  58. message *msg_ref;
  59. struct _message_ref_list *next;
  60. } message_ref_list;
  61. message *new_message(
  62. msg_direction dir,
  63. const pEp_identity *from,
  64. const identity_list *to,
  65. const char *shortmsg
  66. );
  67. void free_message(message *msg);
  68. message_ref_list *new_message_ref_list(message *msg);
  69. void free_message_ref_list(message_ref_list *msg_list);
  70. message_ref_list *message_ref_list_add(message_ref_list *msg_list, message *msg);
  71. typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const message *msg);
  72. typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg, PEP_transport_t **via);
  73. struct _PEP_transport_t {
  74. uint8_t id;
  75. sendto_t sendto;
  76. readnext_t readnext;
  77. bool long_message_supported;
  78. msg_format native_format;
  79. };
  80. typedef uint64_t transports_mask;
  81. PEP_STATUS init_transport_system(PEP_SESSION session);
  82. void release_transport_system(PEP_SESSION session);