Browse Source

transport.hh - make it compile.

master
heck 2 weeks ago
parent
commit
15bb519570
1 changed files with 69 additions and 43 deletions
  1. +69
    -43
      src/transport.hh

+ 69
- 43
src/transport.hh View File

@ -4,67 +4,93 @@
#include <exception>
#include <functional>
#include <pEp/transport_status_code.h>
#include <pEp/types.hh>
namespace pEp {
class Transport {
enum class PEP_transport_id
{
EMAIL,
RCE,
PDL,
SCTP,
CONTROL_CHANNEL
};
enum class PEP_callback_execution_mode
{
PEP_cbe_polling,
// TODO WHAT else?
};
const PEP_transport_id id;
protected:
PEP_transport_status_code actual_status;
protected:
PEP_transport_status_code current_status;
public:
struct TransportError : std::runtime_error {
const PEP_transport_status_code tsc;
TransportError(PEP_transport_status_code tsc) :
std::runtime_error("transport error"), tsc(tsc)
{
}
};
struct ConfigError : std::logic_error {
ConfigError() : std::logic_error("config error") {}
};
class Config {
public:
struct TransportError : std::runtime_error {
const PEP_transport_status_code tsc;
Config() {}
virtual Config& operator=(const Config& second) = 0;
Config(const Config& second)
{
*this = second;
}
TransportError(PEP_transport_status_code tsc) :
std::runtime_error("transport error"), tsc(tsc) { }
};
virtual ~Config() {}
};
struct ConfigError : std::logic_error {
ConfigError() : std::logic_error("config error") { }
};
Transport(PEP_transport_id id) : id(id), current_status(PEP_tsc_shut_down) {}
class Config {
public:
Config() { }
virtual Config& operator=(const Config& second) = 0;
Config(const Config& second) { *this = second; }
virtual ~Config() { }
};
Transport(const Transport&) = delete;
Transport& operator=(const Transport&) = delete;
Transport(PEP_transport_id id) : id(id), actual_status(0x00ffffff) { }
Transport(const Transport&) = delete;
Transport& operator=(const Transport&) = delete;
virtual ~Transport() { }
virtual ~Transport() {}
PEP_transport_id get_id() { return id; }
PEP_transport_id get_id()
{
return id;
}
// the signal_ function register signal handlers
// they must be called while a transport is running, otherwise they
// throw std::logic_error in case the transport is shut down
// the signal_ function register signal handlers
// they must be called while a transport is running, otherwise they
// throw std::logic_error in case the transport is shut down
void
signal_statuschange(std::function(void(PEP_transport_status_code))) = 0;
virtual void signal_statuschange(std::function<void(PEP_transport_status_code)> handler) = 0;
void
signal_sendto_result(std::function(void(std::string,
std::string, PEP_transport_status_code))) = 0;
virtual void signal_sendto_result(
std::function<void(std::string, std::string, PEP_transport_status_code)> handler) = 0;
void
signal_incoming_message(std::function(void(PEP_transport_status_code))) = 0;
virtual void signal_incoming_message(std::function<void(PEP_transport_status_code)> handler) = 0;
virtual void configure(const Config& config) = 0;
virtual void startup(callback_execution cbe = PEP_cbe_polling) = 0;
virtual void shutdown() = 0;
virtual void configure(const Config& config) = 0;
virtual void startup(
PEP_callback_execution_mode cbe = PEP_callback_execution_mode::PEP_cbe_polling) = 0;
virtual void shutdown() = 0;
virtual void sendto(pEp::Message& msg) = 0;
virtual Message recvnext() = 0;
virtual void sendto(Message& msg) = 0;
virtual Message recvnext() = 0;
virtual bool shortmsg_supported() = 0;
virtual bool longmsg_supported() = 0;
virtual bool longmsg_formatted_supported() = 0;
virtual PEP_text_format native_text_format() = 0;
virtual bool shortmsg_supported() = 0;
virtual bool longmsg_supported() = 0;
virtual bool longmsg_formatted_supported() = 0;
virtual PEP_text_format native_text_format() = 0;
};
}
} // namespace pEp
#endif // __PEP_TRANSPORT_HH__

Loading…
Cancel
Save