master
Gernot Kranz 2 weeks ago
parent ad2a8c42c1
commit 6bea5e41c8
  1. 19
      Makefile
  2. 18
      Makefile.conf
  3. 10
      local.conf.example
  4. 26
      src/Makefile
  5. 96
      src/pEpTransportMail.hh

@ -0,0 +1,19 @@
.PHONY: src test install uninstall clean
all: src
src:
$(MAKE) -C src
#test: src
# $(MAKE) -C test
clean:
$(MAKE) -C src clean
# $(MAKE) -C test clean
install:
$(MAKE) -C src install
uninstall:
$(MAKE) -C src uninstall

@ -0,0 +1,18 @@
# Copyright 2022, pEp Foundation
#
# This file may be used under the terms of the GNU General Public License version 3
# see ../LICENSE.txt
######### Header #########
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
# Build config
# Defaults
PREFIX?=$(HOME)
YML2_PATH=$(HOME)/src/yml2
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
YML2_OPTS=--encoding=utf8
# Overrides
-include $(HERE)local.conf

@ -0,0 +1,10 @@
# This is an Example build config file (local.conf)
# you might not need this file, but if the defaults dont work for you
# You can override them here.
# Tweak the values to your needs and rename it to local.conf
############# DIRS #############
# PREFIX=$(HOME)/local
# YML2_PATH=$(HOME)/yml2
# YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
# YML2_OPTS=--encoding=utf8

@ -0,0 +1,26 @@
include ../Makefile.conf
YML2PROC?=yml2proc
PREFIX?=$(HOME)
TARGET=Mail
HEADERS=$(wildcard *.hh *.hxx *.h *.cs)
HEADERS+=$(wildcard ../PublicHeaders/*.h)
TSC=$(wildcard *.tsc)
.PHONY: install uninstall clean
all: $(TARGET)
install: $(TARGET)
mkdir -p $(PREFIX)/include/pEp
mkdir -p $(PREFIX)/lib
cp -v $(HEADERS) $(PREFIX)/include/pEp/
uninstall:
cd $(PREFIX)/include/pEp && rm -vf $(HEADERS)
cd $(PREFIX)/lib && rm -vf $(TARGET)
clean:
rm -f $(TARGET) *.xml *.xsl

@ -0,0 +1,96 @@
#ifndef LIBPEPRCE_PEPRCETRANSPORT_HH
#define LIBPEPRCE_PEPRCETRANSPORT_HH
#include "pEpTox.hh"
#include <pEp/transport.hh>
#include <exception>
#include <string>
#include <functional>
#include <pEp/pEpLog.hh>
namespace pEp {
namespace RCE {
class pEpToxCB;
class pEpTransportRCE : public Transport {
friend pEpToxCB;
public:
class ConfigRCE : public Config {
public:
explicit ConfigRCE(const std::string& userfile);
std::string userfile;
};
explicit pEpTransportRCE(PEP_transport_id id);
// Non-copyable
pEpTransportRCE(const pEpTransportRCE&) = delete;
pEpTransportRCE(const pEpTransportRCE&&) = delete;
pEpTransportRCE& operator=(const pEpTransportRCE&) = delete;
pEpTransportRCE& operator=(const pEpTransportRCE&&) = delete;
// register callbacks
void signal_statuschange(CBStatusChange handler) override;
void signal_sendto_result(CBSendToResult handler) override;
void signal_incoming_message(CBIncomminMessage handler) override;
void configure(const Config& config) override;
void startup() override;
void shutdown() override;
void sendto(::message* msg) override;
::message* recvnext() override;
PEP_transport_id get_id() override;
bool shortmsg_supported() override;
bool longmsg_supported() override;
bool longmsg_formatted_supported() override;
PEP_text_format native_text_format() override;
// pEpTransportRCE specific functions
std::string own_address();
// logger
static bool log_enabled;
Adapter::pEpLog::pEpLogger logger{ "pEpTransportRCE", log_enabled };
virtual ~pEpTransportRCE() = default;
private:
PEP_transport_id id;
// The registered callback functions
CBStatusChange cb_statuschange;
CBSendToResult cb_sendto_result;
CBIncomminMessage cb_incomming_message;
bool cb_statuschange_registered;
bool cb_sendto_result_registered;
bool cb_incomming_message_registered;
std::unique_ptr<peptox::pEpTox> peptox;
std::unique_ptr<pEpToxCB> peptox_callbacks;
std::deque<peptox::MessageRX> rx_queue;
bool allCallbacksRegistered();
void throwInvalidState();
Adapter::pEpLog::pEpLogger& m4gic_logger_n4me = logger;
};
class pEpToxCB : public peptox::CallbacksDefault {
public:
explicit pEpToxCB(pEpTransportRCE& rce);
void cb_connection_status(bool online);
void cb_message_status(const std::string& message_id, peptox::MessageStatusTX status);
void cb_message_incomming(toxcore::Address from, unsigned char channel_nr);
void cb_message_received(const peptox::MessageRX& msg);
private:
pEpTransportRCE& rce;
};
} // namespace RCE
} // namespace pEp
#endif // LIBPEPRCE_PEPRCETRANSPORT_HH
Loading…
Cancel
Save