23static bool directoryChangeNotification =
false;
27#include <sys/select.h>
32void fnotifyEventHandler(
int sig)
34 directoryChangeNotification =
true;
44static const int POLLTIMEOUT = 30 * 60;
46static const int POLLTIMEOUT = 30;
80 bool waitForNotification =
false;
81 int newfd = open((mailboxDir +
"/new").c_str(), O_RDONLY);
82 int curfd = open((mailboxDir +
"/cur").c_str(), O_RDONLY);
86 && !fcntl(newfd, F_NOTIFY, DN_RENAME|DN_DELETE|DN_CREATE)
87 && !fcntl(curfd, F_NOTIFY, DN_RENAME|DN_DELETE|DN_CREATE)) {
88 struct sigaction fnotifyAction;
89 fnotifyAction.sa_handler = fnotifyEventHandler;
90 sigemptyset(&fnotifyAction.sa_mask);
91 fnotifyAction.sa_flags = SA_RESTART;
92 sigaction(SIGUSR1, &fnotifyAction, 0);
93 fcntl(newfd, F_SETSIG, SIGUSR1);
94 fcntl(curfd, F_SETSIG, SIGUSR1);
95 waitForNotification =
true;
100 time_t startTime = time(0);
118 struct timeval tv = {POLLTIMEOUT, 0};
119 int ret = select(maxfd + 1, &readfds, 0, 0, &tv);
125 if (waitForNotification) {
127 <<
" seconds of inactivity." << endl;
134 if (time(0) > startTime + IDLE_TIMEOUT) {
135 bincClient <<
"* BYE Timeout after " << IDLE_TIMEOUT
136 <<
" seconds of inactivity." << endl;
143 if (ret > 0 && FD_ISSET(0, &readfds)) {
149 if (input ==
"DONE") {
152 bincClient <<
"* BAD Syntax error: \"" << input <<
"\"" << endl;
161 bool scanForChanges =
false;
163 if (directoryChangeNotification)
164 scanForChanges =
true;
165 else if (!waitForNotification)
167 scanForChanges =
true;
169 if (scanForChanges) {
170 if (directoryChangeNotification) {
196 if (waitForNotification) {
197 directoryChangeNotification =
false;
200 if (!fcntl(newfd, F_NOTIFY, DN_MODIFY|DN_RENAME|DN_DELETE|DN_CREATE)
201 && !fcntl(curfd, F_NOTIFY, DN_MODIFY|DN_RENAME|DN_DELETE|DN_CREATE)) {
202 struct sigaction fnotifyAction;
203 fnotifyAction.sa_handler = fnotifyEventHandler;
204 sigemptyset(&fnotifyAction.sa_mask);
205 fnotifyAction.sa_flags = SA_RESTART;
206 sigaction(SIGUSR1, &fnotifyAction, 0);
208 waitForNotification =
false;
virtual std::string mailboxToFilename(const std::string &m) const =0
virtual Mailbox * getSelected(void) const
virtual ParseResult parse(Request &) const
ProcessResult process(Depot &, Request &)
const std::string getName(void) const
const std::string getName(void) const
void setName(const std::string &s_in)
bool getUidMode(void) const
void setLastError(const std::string &error) const
const std::string & getLastError(void) const
static Session & getInstance(void)
Declaration of miscellaneous convertion functions.
Declaration of the IODevice class.
Declaration of the IOFactory class.
Declaration of the Mailbox class (Mailbox is logical container)
bool pendingUpdates(Mailbox *, int type, bool rescan, bool showAll=false, bool forceScan=false, bool uidfetchflags=false)
void uppercase(std::string &input)
void trim(std::string &s_in, const std::string &chars=" \t\r\n")
Operator::ParseResult expectCRLF(void)
Declaration of all operators.
Declaration of a recursive descent IMAP command parser.