Akonadi Calendar

blockalarmsattribute.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB,
5 a KDAB Group company, info@kdab.net,
6 author Tobias Koenig <tokoe@kdab.com>
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10
11#include "blockalarmsattribute.h"
12#include <Akonadi/AttributeFactory>
13#include <QByteArray>
14#include <QDataStream>
15#include <QIODevice>
16
17using namespace Akonadi;
18
19class Akonadi::BlockAlarmsAttributePrivate
20{
21public:
22 int audio = 1;
23 int display = 1;
24 int email = 1;
25 int procedure = 1;
26};
27
29 : d(new BlockAlarmsAttributePrivate)
30{
31}
32
34
36{
37 switch (type) {
39 d->audio = block;
40 return;
42 d->display = block;
43 return;
45 d->email = block;
46 return;
48 d->procedure = block;
49 return;
50 default:
51 return;
52 }
53}
54
62
64{
65 switch (type) {
67 return d->audio;
69 return d->display;
71 return d->email;
73 return d->procedure;
74 default:
75 return false;
76 }
77}
78
84
85QByteArray BlockAlarmsAttribute::type() const
86{
87 static const QByteArray sType("BlockAlarmsAttribute");
88 return sType;
89}
90
91BlockAlarmsAttribute *BlockAlarmsAttribute::clone() const
92{
93 auto copy = new BlockAlarmsAttribute();
94 copy->d->audio = d->audio;
95 copy->d->display = d->display;
96 copy->d->email = d->email;
97 copy->d->procedure = d->procedure;
98
99 return copy;
100}
101
102QByteArray BlockAlarmsAttribute::serialized() const
103{
104 QByteArray ba;
106 stream << d->audio;
107 stream << d->display;
108 stream << d->email;
109 stream << d->procedure;
110
111 return ba;
112}
113
114void BlockAlarmsAttribute::deserialize(const QByteArray &data)
115{
116 // Pre-4.11, default behavior
117 if (data.isEmpty()) {
118 d->audio = 1;
119 d->display = 1;
120 d->email = 1;
121 d->procedure = 1;
122 } else {
123 QByteArray ba = data;
124 QDataStream stream(&ba, QIODevice::ReadOnly);
125 int i;
126 stream >> i;
127 d->audio = i;
128 stream >> i;
129 d->display = i;
130 stream >> i;
131 d->email = i;
132 stream >> i;
133 d->procedure = i;
134 }
135}
136
137namespace
138{
139// Anonymous namespace; function is invisible outside this file.
140bool dummy()
141{
143
144 return true;
145}
146
147// Called when this library is loaded.
148const bool registered = dummy();
149} // namespace
static void registerAttribute()
An Attribute that marks that alarms from a calendar collection are blocked.
void blockEverything(bool block=true)
Blocks or unblocks every alarm type.
~BlockAlarmsAttribute() override
Destroys the block alarms attribute.
bool isEverythingBlocked() const
Returns whether all alarms are blocked or not.
bool isAlarmTypeBlocked(KCalendarCore::Alarm::Type type) const
Returns whether given alarm type is blocked or not.
void blockAlarmType(KCalendarCore::Alarm::Type type, bool block=true)
Blocks or unblocks given alarm type.
BlockAlarmsAttribute()
Creates a new block alarms attribute.
FreeBusyManager::Singleton.
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:52:11 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.