|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <list> //what for?
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <unistd.h> // for sleep(). only works for unixes
|
|
|
|
|
|
|
|
|
|
pEp::Transport::Config::~Config() {}
|
|
|
|
|
|
|
|
|
@ -73,17 +74,10 @@ namespace pEp {
|
|
|
|
|
// and then populate rx_queue via conn_imap.select()
|
|
|
|
|
conn_imap = new mailio::imaps(login_imap.server, login_imap.port);
|
|
|
|
|
conn_imap->authenticate(login_imap.username, login_imap.passphrase, login_imap.auth_method);
|
|
|
|
|
////should be repeated in different thread:
|
|
|
|
|
//conn_imap->search( welp, mailio atm doesn't support to search for unread messages only…
|
|
|
|
|
//we could try something like:
|
|
|
|
|
mailio::imap::mailbox_stat_t inbox_stat = conn_imap->select("inbox");
|
|
|
|
|
print_stats(inbox_stat);
|
|
|
|
|
if (inbox_stat.messages_first_unseen)
|
|
|
|
|
rx_queue.push(inbox_stat.messages_first_unseen);
|
|
|
|
|
//but that only gives us one unread email.
|
|
|
|
|
//shoouuld we use pop3 instead?
|
|
|
|
|
//that differentiates between unread and not-yet-fetched mails.
|
|
|
|
|
//or should we abandon mailio and use vmime or mailcore2?
|
|
|
|
|
if (!protocol_thread.joinable()) {
|
|
|
|
|
protocol_thread_stop.store(false);
|
|
|
|
|
protocol_thread = std::thread(&pEpTransportMail::worker, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pEpTransportMail::shutdown()
|
|
|
|
@ -235,8 +229,25 @@ namespace pEp {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private
|
|
|
|
|
void pEpTransportMail::throwInvalidState()
|
|
|
|
|
void pEpTransportMail::throwInvalidState() {}
|
|
|
|
|
|
|
|
|
|
// private
|
|
|
|
|
void pEpTransportMail::worker()
|
|
|
|
|
{
|
|
|
|
|
mailio::imap::mailbox_stat_t inbox_stat;
|
|
|
|
|
while (!protocol_thread_stop.load()) {
|
|
|
|
|
//conn_imap->search( welp, mailio atm doesn't support to search for unread messages only…
|
|
|
|
|
//we could try something like:
|
|
|
|
|
inbox_stat = conn_imap->select("inbox");
|
|
|
|
|
print_stats(inbox_stat);
|
|
|
|
|
if (inbox_stat.messages_first_unseen)
|
|
|
|
|
rx_queue.push(inbox_stat.messages_first_unseen);
|
|
|
|
|
//but that only gives us one unread email.
|
|
|
|
|
//shoouuld we use pop3 instead?
|
|
|
|
|
//that differentiates between unread and not-yet-fetched mails.
|
|
|
|
|
//or should we abandon mailio and use vmime or mailcore2?
|
|
|
|
|
sleep(60);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// pEpTox Callbacks-------------------------------------------------------------------------
|
|
|
|
|