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