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.
50 lines
1.4 KiB
50 lines
1.4 KiB
#include <protocol/protocol.hpp>
|
|
#include <mail.hpp>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <unordered_map>
|
|
#include <iostream>
|
|
#include <functional>
|
|
|
|
const bool debug = true;
|
|
|
|
using namespace std;
|
|
|
|
mail::session_map_t mail_messages;
|
|
|
|
void on_ready(protocol::protocol_t& protocol, protocol::message_t message) {
|
|
debug && cerr << "Ready" << endl;
|
|
protocol.send({"register", "filter", "smtp-in", "data"});
|
|
protocol.send({"register", "filter", "smtp-in", "data-line"});
|
|
protocol.send({"register", "filter", "smtp-in", "commit"});
|
|
protocol.send({"register", "ready"});
|
|
}
|
|
|
|
void on_data(protocol::protocol_t& protocol, protocol::message_t message) {
|
|
mail_messages.emplace(protocol::session_from(message), mail::message_t{});
|
|
}
|
|
|
|
void on_dataline(protocol::protocol_t& protocol, protocol::message_t message) {
|
|
debug && cerr << "Dataline" << endl;
|
|
}
|
|
|
|
void on_commit(protocol::protocol_t& protocol, protocol::message_t message) {
|
|
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
protocol::ios_protocol_t protocol(cin, cout);
|
|
|
|
protocol::handler_map_t handlers;
|
|
handlers.emplace("config|ready", on_ready);
|
|
handlers.emplace("filter|*|*|smtp-in|data", on_data);
|
|
handlers.emplace("filter|*|*|smtp-in|data-line", on_dataline);
|
|
handlers.emplace("filter|*|*|smtp-in|commit", on_commit);
|
|
protocol.set_handlers(handlers);
|
|
|
|
protocol.run();
|
|
|
|
return 0;
|
|
} |