KWeatherCore

capalertmessage.h
1/*
2 * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6#pragma once
7#include "kweathercore/kweathercore_export.h"
8
9#include <QDateTime>
10#include <QMetaType>
11#include <QSharedDataPointer>
12#include <vector>
13
14namespace KWeatherCore
15{
16class CAPAlertInfo;
17class CAPAlertMessagePrivate;
18class CAPReference;
19/**
20 * @short Represents a single CAP Alert Message
21 *
22 * This class contains the information of a parsed CAP alert message.
23 * @see CAPAlertInfo
24 * @see https://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2.html $3.2.1
25 *
26 * @author Anjani Kumar <anjanik012@gmail.com>
27 */
28class KWEATHERCORE_EXPORT CAPAlertMessage
29{
30 Q_GADGET
31 Q_PROPERTY(QString identifier READ identifier)
32 Q_PROPERTY(QString sender READ sender)
33 Q_PROPERTY(QDateTime sentTime READ sentTime)
34 Q_PROPERTY(QString note READ note)
35 Q_PROPERTY(Status status READ status)
36 Q_PROPERTY(MessageType messageType READ messageType)
37 Q_PROPERTY(Scope scope READ scope)
38public:
39 /** The code denoting the appropriate handling of the alert message. */
40 enum class Status {
41 UnknownStatus,
42 Actual, ///< Actionable by all targeted recipients
43 Exercise, ///< Actionable only by designated exercise participants
44 System, //< For messages that support alert network internal functions
45 Test, ///< Technical testing only, all recipients disregard
46 Draft, ///< A preliminary template or draft, not actionable in its current form
47 };
48 Q_ENUM(Status)
49 enum class MessageType {
50 UnknownMessageType,
51 Alert, ///< Initial information requiring attention by targeted recipients
52 Update, ///< Updates and supercedes the earlier message(s) identified in references()
53 Cancel, ///< Cancels the earlier message(s) identified in references()
54 Acknowledge, ///< Acknowledges receipt and acceptance of the message(s) identified in references()
55 Error, ///< Indicates rejection of the message(s) identified in references()
56 };
57 Q_ENUM(MessageType)
58 enum class Scope {
59 UnknownScope,
60 Public, ///< For general dissemination to unrestricted audiences
61 Restricted, ///< For dissemination only to users with a known operational requirement
62 Private, ///< For dissemination only to specified addresses
63 };
64 Q_ENUM(Scope)
65
66 /**
67 * Default constructor, Status, MsgType, Scope
68 * are set to Unknown
69 */
71 CAPAlertMessage(const CAPAlertMessage &other);
72 CAPAlertMessage(CAPAlertMessage &&other) noexcept;
74
75 /**
76 * Unique alert message identifier.
77 */
78 QString identifier() const;
79 /**
80 * The identifier of the sender of the alert message.
81 */
82 QString sender() const;
83 /**
84 * The time and date of the origination of the alert message.
85 */
86 QDateTime sentTime() const;
87 /**
88 * The code denoting the appropriate handling of the alert message.
89 * Returns UnknownStatus if not set.
90 */
91 Status status() const;
92 /**
93 * The code denoting the nature of the alert message.
94 * Returns UnknownMsgType if not set.
95 */
96 MessageType messageType() const;
97 /**
98 * The code denoting the intended distribution of the alert message.
99 * Returns UnknownScope if not set.
100 */
101 Scope scope() const;
102 /**
103 * The text describing the purpose or significance of the alert message.
104 * Relevant for Exercise and Error status.
105 */
106 QString note() const;
107 /**
108 * The alert info elements of this alert message.
109 * @see CAPAlertInfo
110 */
111 const std::vector<CAPAlertInfo> &alertInfos() const;
112 /**
113 * References to previous CAP alert messages.
114 * Relevant for Update, Cancel and Ack message types.
115 */
116 const std::vector<CAPReference> &references() const;
117 /**
118 * Reference of this CAP alert message.
119 * @see references()
120 */
121 CAPReference ownReference() const;
122
123 ///@cond internal
124 // only for internal use by CAPParser
125 void setIdentifier(const QString &identifier);
126 void setSender(const QString &sender);
127 void setSentTime(const QDateTime &dateTime);
128 void setStatus(Status status);
129 void setMessageType(MessageType msgType);
130 void setScope(Scope scope);
131 void setNote(const QString &note);
132 void addInfo(CAPAlertInfo &&alertInfo);
133 void setReferences(std::vector<CAPReference> &&references);
134 ///@endcond
135
136 CAPAlertMessage &operator=(const CAPAlertMessage &other);
137 CAPAlertMessage &operator=(CAPAlertMessage &&other) noexcept;
138
139private:
141};
142}
143
144Q_DECLARE_METATYPE(KWeatherCore::CAPAlertMessage)
Represents a single CAP alert message info element.
Represents a single CAP Alert Message.
Status
The code denoting the appropriate handling of the alert message.
A reference to a previous CAP alert message.
Q_SCRIPTABLE CaptureState status()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:55:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.