• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
  • calendar
blockalarmsattribute.cpp
1 /*
2  Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
3 
4  Copyright (C) 2010 Klarälvdalens Datakonsult AB,
5  a KDAB Group company, info@kdab.net,
6  author Tobias Koenig <tokoe@kdab.com>
7 
8  This library is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Library General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or (at your
11  option) any later version.
12 
13  This library is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16  License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to the
20  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 */
23 
24 #include "blockalarmsattribute.h"
25 #include <akonadi/attributefactory.h>
26 #include <QtCore/QByteArray>
27 #include <QtCore/QDataStream>
28 
29 using namespace Akonadi;
30 
31 class BlockAlarmsAttribute::Private
32 {
33 public:
34  Private():
35  audio(1),
36  display(1),
37  email(1),
38  procedure(1)
39  { }
40 
41  int audio : 1;
42  int display : 1;
43  int email : 1;
44  int procedure : 1;
45 };
46 
47 BlockAlarmsAttribute::BlockAlarmsAttribute():
48  d(new Private)
49 {
50 }
51 
52 BlockAlarmsAttribute::~BlockAlarmsAttribute()
53 {
54  delete d;
55 }
56 
57 void BlockAlarmsAttribute::blockAlarmType(KCalCore::Alarm::Type type, bool block)
58 {
59  switch (type) {
60  case KCalCore::Alarm::Audio:
61  d->audio = block;
62  return;
63  case KCalCore::Alarm::Display:
64  d->display = block;
65  return;
66  case KCalCore::Alarm::Email:
67  d->email = block;
68  return;
69  case KCalCore::Alarm::Procedure:
70  d->procedure = block;
71  return;
72  default:
73  return;
74  }
75 }
76 
77 bool BlockAlarmsAttribute::isAlarmTypeBlocked(KCalCore::Alarm::Type type) const
78 {
79  switch (type) {
80  case KCalCore::Alarm::Audio:
81  return d->audio;
82  case KCalCore::Alarm::Display:
83  return d->display;
84  case KCalCore::Alarm::Email:
85  return d->email;
86  case KCalCore::Alarm::Procedure:
87  return d->procedure;
88  default:
89  return false;
90  }
91 }
92 
93 QByteArray BlockAlarmsAttribute::type() const
94 {
95  static const QByteArray sType( "BlockAlarmsAttribute" );
96  return sType;
97 }
98 
99 BlockAlarmsAttribute *BlockAlarmsAttribute::clone() const
100 {
101  BlockAlarmsAttribute *copy = new BlockAlarmsAttribute();
102  copy->d->audio = d->audio;
103  copy->d->display = d->display;
104  copy->d->email = d->email;
105  copy->d->procedure = d->procedure;
106 
107  return copy;
108 }
109 
110 QByteArray BlockAlarmsAttribute::serialized() const
111 {
112  QByteArray ba;
113  QDataStream stream(&ba, QIODevice::WriteOnly);
114  stream << d->audio;
115  stream << d->display;
116  stream << d->email;
117  stream << d->procedure;
118 
119  return ba;
120 }
121 
122 void BlockAlarmsAttribute::deserialize(const QByteArray &data)
123 {
124  // Pre-4.11, default behavior
125  if (data.isEmpty()) {
126  d->audio = true;
127  d->display = true;
128  d->email = true;
129  d->procedure = true;
130  } else {
131  QByteArray ba = data;
132  QDataStream stream(&ba, QIODevice::ReadOnly);
133  int i;
134  stream >> i;
135  d->audio = i;
136  stream >> i;
137  d->display = i;
138  stream >> i;
139  d->email = i;
140  stream >> i;
141  d->procedure = i;
142  }
143 }
144 
145 #ifndef KDELIBS_STATIC_LIBS
146 namespace {
147 
148 // Anonymous namespace; function is invisible outside this file.
149 bool dummy()
150 {
151  Akonadi::AttributeFactory::registerAttribute<Akonadi::BlockAlarmsAttribute>();
152 
153  return true;
154 }
155 
156 // Called when this library is loaded.
157 const bool registered = dummy();
158 
159 } // namespace
160 
161 #else
162 
163 extern bool ___Akonadi____INIT()
164 {
165  Akonadi::AttributeFactory::registerAttribute<Akonadi::BlockAlarmsAttribute>();
166 
167  return true;
168 }
169 
170 #endif
Akonadi::BlockAlarmsAttribute::deserialize
void deserialize(const QByteArray &data)
Reimplemented from Attribute.
Definition: blockalarmsattribute.cpp:122
Akonadi::BlockAlarmsAttribute::serialized
QByteArray serialized() const
Reimplemented from Attribute.
Definition: blockalarmsattribute.cpp:110
QByteArray
QDataStream
QByteArray::isEmpty
bool isEmpty() const
Akonadi::BlockAlarmsAttribute::type
QByteArray type() const
Reimplemented from Attribute.
Definition: blockalarmsattribute.cpp:93
Akonadi::BlockAlarmsAttribute::clone
BlockAlarmsAttribute * clone() const
Reimplemented from Attribute.
Definition: blockalarmsattribute.cpp:99
Akonadi::BlockAlarmsAttribute::BlockAlarmsAttribute
BlockAlarmsAttribute()
Creates a new block alarms attribute.
Definition: blockalarmsattribute.cpp:47
Akonadi::BlockAlarmsAttribute::~BlockAlarmsAttribute
~BlockAlarmsAttribute()
Destroys the block alarms attribute.
Definition: blockalarmsattribute.cpp:52
Akonadi::BlockAlarmsAttribute::isAlarmTypeBlocked
bool isAlarmTypeBlocked(KCalCore::Alarm::Type type) const
Returns whether given alarm type is blocked or not.
Definition: blockalarmsattribute.cpp:77
Akonadi::BlockAlarmsAttribute::blockAlarmType
void blockAlarmType(KCalCore::Alarm::Type type, bool block=true)
Blocks or unblocks given alarm type.
Definition: blockalarmsattribute.cpp:57
Akonadi::BlockAlarmsAttribute
An Attribute that marks that alarms from a calendar collection are blocked.
Definition: blockalarmsattribute.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal