Mercurial > thymian
comparison 3rdparty/vmime/examples/example6_timeoutHandler.hpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 | |
| 2 | |
| 3 /** Time out handler. | |
| 4 * Used to stop the current operation after too much time, or if the user | |
| 5 * requested cancellation. | |
| 6 */ | |
| 7 class timeoutHandler : public vmime::net::timeoutHandler | |
| 8 { | |
| 9 public: | |
| 10 | |
| 11 bool isTimeOut() | |
| 12 { | |
| 13 // This is a cancellation point: return true if you want to cancel | |
| 14 // the current operation. If you return true, handleTimeOut() will | |
| 15 // be called just after this, and before actually cancelling the | |
| 16 // operation | |
| 17 return false; | |
| 18 } | |
| 19 | |
| 20 void resetTimeOut() | |
| 21 { | |
| 22 // Called at the beginning of an operation (eg. connecting, | |
| 23 // a read() or a write() on a socket...) | |
| 24 } | |
| 25 | |
| 26 bool handleTimeOut() | |
| 27 { | |
| 28 // If isTimeOut() returned true, this function will be called. This | |
| 29 // allows you to interact with the user, ie. display a prompt to | |
| 30 // know whether he wants to cancel the operation. | |
| 31 | |
| 32 // If you return true here, the operation will be actually cancelled. | |
| 33 // If not, the time out is reset and the operation continues. | |
| 34 return true; | |
| 35 } | |
| 36 }; | |
| 37 | |
| 38 | |
| 39 class timeoutHandlerFactory : public vmime::net::timeoutHandlerFactory | |
| 40 { | |
| 41 public: | |
| 42 | |
| 43 vmime::shared_ptr <vmime::net::timeoutHandler> create() | |
| 44 { | |
| 45 return vmime::make_shared <timeoutHandler>(); | |
| 46 } | |
| 47 }; | |
| 48 |
