icinga2/lib/icinga/comment.ti
Yonas Habteab 91c7e60df8 Replace all existing copyright headers with SPDX headers
I've used the following command to replace the original copyright header
lines in a C-style comment block:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

For files that use shell-style comments (#) like CMakeLists.txt, I've
used this command:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

And for SQL files:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
2026-02-04 14:00:05 +01:00

83 lines
2 KiB
Text

// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "base/configobject.hpp"
#include "base/utility.hpp"
#impl_include "icinga/service.hpp"
library icinga;
namespace icinga
{
code {{{
/**
* The type of a service comment.
*
* @ingroup icinga
*/
enum CommentType
{
CommentUser = 1,
CommentAcknowledgement = 4
};
class CommentNameComposer : public NameComposer
{
public:
virtual String MakeName(const String& shortName, const Object::Ptr& context) const override;
virtual Dictionary::Ptr ParseName(const String& name) const override;
};
}}}
class Comment : ConfigObject < CommentNameComposer
{
load_after Host;
load_after Service;
[config, no_user_modify, protected, required, navigation(host)] name(Host) host_name {
navigate {{{
return Host::GetByName(GetHostName());
}}}
};
[config, no_user_modify, protected, navigation(service)] String service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
DependencyGraph::RemoveDependency(this, service.get());
}
if (!newValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
DependencyGraph::AddDependency(this, service.get());
}
}}}
navigate {{{
if (!GetServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetHostName());
if (host)
return host->GetServiceByShortName(GetServiceName());
}
return nullptr;
}}}
};
[config] Timestamp entry_time {
default {{{ return Utility::GetTime(); }}}
};
[config, enum] CommentType entry_type {
default {{{ return CommentUser; }}}
};
[config, no_user_view, no_user_modify] bool sticky;
[config, required] String author;
[config, required] String text;
[config] bool persistent;
[config] Timestamp expire_time;
[state] int legacy_id;
[no_user_view, no_user_modify] String removed_by;
[no_user_view, no_user_modify] Timestamp remove_time;
};
}