2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-11-09 21:19:52 +01:00
|
|
|
|
|
|
|
#ifndef COMMENT_H
|
|
|
|
#define COMMENT_H
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
2018-01-18 13:50:38 +01:00
|
|
|
#include "icinga/comment-ti.hpp"
|
|
|
|
#include "icinga/checkable-ti.hpp"
|
2015-08-20 17:18:48 +02:00
|
|
|
#include "remote/messageorigin.hpp"
|
2013-11-09 21:19:52 +01:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2015-08-20 17:18:48 +02:00
|
|
|
* A comment.
|
2013-11-09 21:19:52 +01:00
|
|
|
*
|
|
|
|
* @ingroup icinga
|
|
|
|
*/
|
2018-01-04 06:11:04 +01:00
|
|
|
class Comment final : public ObjectImpl<Comment>
|
2013-11-09 21:19:52 +01:00
|
|
|
{
|
|
|
|
public:
|
2014-11-03 00:44:04 +01:00
|
|
|
DECLARE_OBJECT(Comment);
|
2015-08-20 17:18:48 +02:00
|
|
|
DECLARE_OBJECTNAME(Comment);
|
|
|
|
|
|
|
|
static boost::signals2::signal<void (const Comment::Ptr&)> OnCommentAdded;
|
|
|
|
static boost::signals2::signal<void (const Comment::Ptr&)> OnCommentRemoved;
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
intrusive_ptr<Checkable> GetCheckable() const;
|
2013-11-09 22:16:53 +01:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
bool IsExpired() const;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
static int GetNextCommentID();
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
static String AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
|
2017-12-19 15:50:05 +01:00
|
|
|
const String& author, const String& text, bool persistent, double expireTime,
|
|
|
|
const String& id = String(), const MessageOrigin::Ptr& origin = nullptr);
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2017-11-30 08:36:35 +01:00
|
|
|
static void RemoveComment(const String& id, const MessageOrigin::Ptr& origin = nullptr);
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
static String GetCommentIDFromLegacyID(int id);
|
|
|
|
|
|
|
|
protected:
|
2018-01-04 05:12:56 +01:00
|
|
|
void OnAllConfigLoaded() override;
|
|
|
|
void Start(bool runtimeCreated) override;
|
|
|
|
void Stop(bool runtimeRemoved) override;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
private:
|
2015-10-29 08:06:03 +01:00
|
|
|
ObjectImpl<Checkable>::Ptr m_Checkable;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
static void CommentsExpireTimerHandler();
|
2013-11-09 21:19:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* COMMENT_H */
|