Add OnNewNotificationResult signal and ProcessNotificationResult handler

This commit is contained in:
Michael Friedrich 2018-07-25 08:53:44 +02:00
parent 9621fd2e4b
commit ac483f2a8a
2 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,7 @@ std::map<String, int> Notification::m_StateFilterMap;
std::map<String, int> Notification::m_TypeFilterMap; std::map<String, int> Notification::m_TypeFilterMap;
boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNextNotificationChanged; boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNextNotificationChanged;
boost::signals2::signal<void (const Notification::Ptr&, const NotificationResult::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNewNotificationResult;
String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
{ {
@ -550,6 +551,15 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
} }
} }
void Notification::ProcessNotificationResult(const NotificationResult::Ptr& nr, const MessageOrigin::Ptr& origin)
{
if (!nr)
return;
/* Notify cluster, API and feature events. */
OnNewNotificationResult(this, nr, origin);
}
int icinga::ServiceStateToFilter(ServiceState state) int icinga::ServiceStateToFilter(ServiceState state)
{ {
switch (state) { switch (state) {

View File

@ -10,6 +10,7 @@
#include "icinga/usergroup.hpp" #include "icinga/usergroup.hpp"
#include "icinga/timeperiod.hpp" #include "icinga/timeperiod.hpp"
#include "icinga/checkresult.hpp" #include "icinga/checkresult.hpp"
#include "icinga/notificationresult.hpp"
#include "remote/endpoint.hpp" #include "remote/endpoint.hpp"
#include "remote/messageorigin.hpp" #include "remote/messageorigin.hpp"
#include "base/array.hpp" #include "base/array.hpp"
@ -82,10 +83,13 @@ public:
Endpoint::Ptr GetCommandEndpoint() const; Endpoint::Ptr GetCommandEndpoint() const;
void ProcessNotificationResult(const NotificationResult::Ptr& nr, const MessageOrigin::Ptr& origin);
static String NotificationTypeToString(NotificationType type); static String NotificationTypeToString(NotificationType type);
static String NotificationFilterToString(int filter, const std::map<String, int>& filterMap); static String NotificationFilterToString(int filter, const std::map<String, int>& filterMap);
static boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> OnNextNotificationChanged; static boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> OnNextNotificationChanged;
static boost::signals2::signal<void (const Notification::Ptr&, const NotificationResult::Ptr&, const MessageOrigin::Ptr&)> OnNewNotificationResult;
void Validate(int types, const ValidationUtils& utils) override; void Validate(int types, const ValidationUtils& utils) override;