1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2002 Tobias Koenig <tokoe@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KCONTACTS_SECRECY_H
9#define KCONTACTS_SECRECY_H
10
11#include "kcontacts_export.h"
12#include <QList>
13#include <QSharedDataPointer>
14
15namespace KContacts
16{
17/** Describes the confidentiality of an addressee. */
18class KCONTACTS_EXPORT Secrecy
19{
20 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Secrecy &);
21 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Secrecy &);
22
23public:
24 /**
25 * Secrecy types
26 *
27 * @li Public - for public access
28 * @li Private - only private access
29 * @li Confidential - access for confidential persons
30 */
31 enum Type {
32 Public,
33 Private,
34 Confidential,
35 Invalid,
36 };
37
38 /**
39 * List of secrecy types.
40 */
41 typedef QList<Type> TypeList;
42
43 /**
44 * Creates a new secrecy of the given type.
45 *
46 * @param type The secrecy type. @see Type
47 */
48 Secrecy(Type type = Invalid);
49
50 /**
51 * Copy constructor.
52 */
53 Secrecy(const Secrecy &other);
54
55 /**
56 * Destroys the secrecy.
57 */
58 ~Secrecy();
59
60 Secrecy &operator=(const Secrecy &other);
61
62 Q_REQUIRED_RESULT bool operator==(const Secrecy &other) const;
63 Q_REQUIRED_RESULT bool operator!=(const Secrecy &other) const;
64
65 /**
66 * Returns if the Secrecy object has a valid value.
67 */
68 Q_REQUIRED_RESULT bool isValid() const;
69
70 /**
71 * Sets the @p type.
72 *
73 * @param type The #Type of secrecy
74 */
75 void setType(Type type);
76
77 /**
78 * Returns the type.
79 */
80 Q_REQUIRED_RESULT Type type() const;
81
82 /**
83 * Returns a list of all available secrecy types.
84 */
85 Q_REQUIRED_RESULT static TypeList typeList();
86
87 /**
88 * Returns a translated label for a given secrecy @p type.
89 */
90 Q_REQUIRED_RESULT static QString typeLabel(Type type);
91
92 /**
93 * Returns a string representation of the secrecy.
94 */
95 Q_REQUIRED_RESULT QString toString() const;
96
97private:
98 class PrivateData;
99 QSharedDataPointer<PrivateData> d;
100};
101
102/**
103 * Serializes the @p secrecy object into the @p stream.
104 */
105KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Secrecy &secrecy);
106
107/**
108 * Initializes the @p secrecy object from the @p stream.
109 */
110KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Secrecy &secrecy);
111}
112Q_DECLARE_TYPEINFO(KContacts::Secrecy, Q_RELOCATABLE_TYPE);
113#endif
114

source code of kcontacts/src/secrecy.h