diff options
author | Vincent Richard <[email protected]> | 2014-03-16 21:52:40 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2014-03-16 21:52:40 +0000 |
commit | 84e570bbbb1188d2bcd3f03ff519fbc9217e624a (patch) | |
tree | 392b7e600433ee3fecd0c13e4020754477b42241 /examples/example6_timeoutHandler.hpp | |
parent | Modified IMAP parser constructor to make testing easier. (diff) | |
download | vmime-84e570bbbb1188d2bcd3f03ff519fbc9217e624a.tar.gz vmime-84e570bbbb1188d2bcd3f03ff519fbc9217e624a.zip |
Connection trace facility.
Diffstat (limited to 'examples/example6_timeoutHandler.hpp')
-rw-r--r-- | examples/example6_timeoutHandler.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/examples/example6_timeoutHandler.hpp b/examples/example6_timeoutHandler.hpp new file mode 100644 index 00000000..7c2eb0e2 --- /dev/null +++ b/examples/example6_timeoutHandler.hpp @@ -0,0 +1,48 @@ + + +/** Time out handler. + * Used to stop the current operation after too much time, or if the user + * requested cancellation. + */ +class timeoutHandler : public vmime::net::timeoutHandler +{ +public: + + bool isTimeOut() + { + // This is a cancellation point: return true if you want to cancel + // the current operation. If you return true, handleTimeOut() will + // be called just after this, and before actually cancelling the + // operation + return false; + } + + void resetTimeOut() + { + // Called at the beginning of an operation (eg. connecting, + // a read() or a write() on a socket...) + } + + bool handleTimeOut() + { + // If isTimeOut() returned true, this function will be called. This + // allows you to interact with the user, ie. display a prompt to + // know whether he wants to cancel the operation. + + // If you return true here, the operation will be actually cancelled. + // If not, the time out is reset and the operation continues. + return true; + } +}; + + +class timeoutHandlerFactory : public vmime::net::timeoutHandlerFactory +{ +public: + + vmime::shared_ptr <vmime::net::timeoutHandler> create() + { + return vmime::make_shared <timeoutHandler>(); + } +}; + |