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.

127 lines
3.1 KiB

7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
7 years ago
7 years ago
  1. /**
  2. * @file transport.h
  3. * @brief transport structs
  4. * @license GNU General Public License 3.0 - see LICENSE.txt
  5. */
  6. #ifndef TRANSPORT_H
  7. #define TRANSPORT_H
  8. #include "pEpEngine.h"
  9. #include "message.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @enum PEP_transport_id
  15. *
  16. * @brief TODO
  17. *
  18. */
  19. typedef enum _PEP_transport_id {
  20. // auto transport chooses transport per message automatically
  21. PEP_trans_auto = 0,
  22. // PEP_trans_Email = 0x01,
  23. // PEP_trans_RCE = 0x02,
  24. PEP_trans__count,
  25. PEP_trans_CC = 0xfe
  26. } PEP_transport_id;
  27. typedef struct _transport_config {
  28. // set size field when initializing
  29. size_t size;
  30. // expand here
  31. // in C++ this must be POD
  32. } transport_config_t;
  33. // transports are delivering the transport status code
  34. // this is defined here:
  35. // https://dev.pep.foundation/Engine/TransportStatusCode
  36. typedef uint32_t PEP_transport_status_code;
  37. typedef struct _PEP_transport_t PEP_transport_t;
  38. // functions offered by transport
  39. typedef PEP_STATUS (*configure_transport_t)(PEP_transport_t *transport,
  40. transport_config_t *config, PEP_transport_status_code *tsc);
  41. typedef PEP_STATUS (*startup_transport_t)(PEP_transport_t *transport,
  42. PEP_transport_status_code *tsc);
  43. typedef PEP_STATUS (*shutdown_transport_t)(PEP_transport_t *transport,
  44. PEP_transport_status_code *tsc);
  45. typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, message *msg,
  46. PEP_transport_status_code *tsc);
  47. typedef PEP_STATUS (*recvnext_t)(PEP_SESSION session, message **msg,
  48. PEP_transport_status_code *tsc);
  49. // callbacks
  50. typedef PEP_STATUS (*signal_statuschange_t)(PEP_transport_id id,
  51. PEP_transport_status_code tsc);
  52. typedef PEP_STATUS (*signal_sendto_result_t)(PEP_transport_id id, char *message_id,
  53. char *address, PEP_transport_status_code tsc);
  54. // call this to receive signals
  55. typedef enum _callback_execution {
  56. PEP_cbe_polling = 0, // execute callbacks immediately only
  57. PEP_cbe_async, // execute callbacks later on any thread
  58. // the last one is for the transport system only
  59. // do not implement it in transports
  60. PEP_cbe_blocking = 255
  61. } callback_execution;
  62. typedef PEP_STATUS (*notify_transport_t)(signal_statuschange_t status_change,
  63. signal_sendto_result_t sendto_result, callback_execution cbe);
  64. /**
  65. * @struct _PEP_transport_t
  66. *
  67. * @brief TODO
  68. *
  69. */
  70. struct _PEP_transport_t {
  71. PEP_transport_id id; // transport ID
  72. const char *uri_scheme; // URI scheme this transport is
  73. // covering
  74. // functions offered by transport
  75. configure_transport_t configure;
  76. startup_transport_t startup;
  77. shutdown_transport_t shutdown;
  78. sendto_t sendto;
  79. recvnext_t recvnext;
  80. notify_transport_t notify;
  81. bool is_online_transport;
  82. bool shortmsg_supported;
  83. bool longmsg_supported;
  84. bool longmsg_formatted_supported;
  85. PEP_text_format native_text_format; // native format of the transport
  86. };
  87. extern PEP_transport_t transports[PEP_trans__count];
  88. typedef uint64_t transports_mask;
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif