diff options
Diffstat (limited to 'Swiften/Events/MessageEvent.h')
-rw-r--r-- | Swiften/Events/MessageEvent.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Swiften/Events/MessageEvent.h b/Swiften/Events/MessageEvent.h new file mode 100644 index 0000000..27eecaf --- /dev/null +++ b/Swiften/Events/MessageEvent.h @@ -0,0 +1,31 @@ +#ifndef SWIFTEN_MessageEvent_H +#define SWIFTEN_MessageEvent_H + +#include <cassert> + +#include "Swiften/Elements/Message.h" + +#include <boost/shared_ptr.hpp> + +namespace Swift { + class MessageEvent { + public: + MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza){} + boost::shared_ptr<Message> getStanza() {return stanza_;} + boost::signal<void()> onRead; + + bool isReadable() { + return getStanza()->isError() || !getStanza()->getBody().isEmpty(); + } + + void read() { + assert (isReadable()); + onRead(); + } + + private: + boost::shared_ptr<Message> stanza_; + }; +} + +#endif |