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

akonadi

  • sources
  • kde-4.12
  • 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  return "BlockAlarmsAttribute";
96 }
97 
98 BlockAlarmsAttribute *BlockAlarmsAttribute::clone() const
99 {
100  BlockAlarmsAttribute *copy = new BlockAlarmsAttribute();
101  copy->d->audio = d->audio;
102  copy->d->display = d->display;
103  copy->d->email = d->email;
104  copy->d->procedure = d->procedure;
105 
106  return copy;
107 }
108 
109 QByteArray BlockAlarmsAttribute::serialized() const
110 {
111  QByteArray ba;
112  QDataStream stream(&ba, QIODevice::WriteOnly);
113  stream << d->audio;
114  stream << d->display;
115  stream << d->email;
116  stream << d->procedure;
117 
118  return ba;
119 }
120 
121 void BlockAlarmsAttribute::deserialize(const QByteArray &data)
122 {
123  // Pre-4.11, default behavior
124  if (data.isEmpty()) {
125  d->audio = true;
126  d->display = true;
127  d->email = true;
128  d->procedure = true;
129  } else {
130  QByteArray ba = data;
131  QDataStream stream(&ba, QIODevice::ReadOnly);
132  int i;
133  stream >> i;
134  d->audio = i;
135  stream >> i;
136  d->display = i;
137  stream >> i;
138  d->email = i;
139  stream >> i;
140  d->procedure = i;
141  }
142 }
143 
144 #ifndef KDELIBS_STATIC_LIBS
145 namespace {
146 
147 // Anonymous namespace; function is invisible outside this file.
148 bool dummy()
149 {
150  Akonadi::AttributeFactory::registerAttribute<Akonadi::BlockAlarmsAttribute>();
151 
152  return true;
153 }
154 
155 // Called when this library is loaded.
156 const bool registered = dummy();
157 
158 } // namespace
159 
160 #else
161 
162 extern bool ___Akonadi____INIT()
163 {
164  Akonadi::AttributeFactory::registerAttribute<Akonadi::BlockAlarmsAttribute>();
165 
166  return true;
167 }
168 
169 #endif
Akonadi::BlockAlarmsAttribute::deserialize
void deserialize(const QByteArray &data)
Reimplemented from Attribute.
Definition: blockalarmsattribute.cpp:121
Akonadi::BlockAlarmsAttribute::serialized
QByteArray serialized() const
Reimplemented from Attribute.
Definition: blockalarmsattribute.cpp:109
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:98
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-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:26 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
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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