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

KAlarm Library

  • kalarmcal
compatibilityattribute.cpp
1/*
2 * compatibilityattribute.cpp - Akonadi attribute holding Collection compatibility
3 * This file is part of kalarmcal library, which provides access to KAlarm
4 * calendar data.
5 * Copyright © 2011 by David Jarvie <djarvie@kde.org>
6 *
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Library General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22
23#include "compatibilityattribute.h"
24
25#include <kdebug.h>
26
27namespace KAlarmCal
28{
29
30class CompatibilityAttribute::Private
31{
32 public:
33 Private()
34 : mCompatibility(KACalendar::Incompatible),
35 mVersion(KACalendar::IncompatibleFormat)
36 {}
37
38 KACalendar::Compat mCompatibility; // calendar compatibility with current KAlarm format
39 int mVersion; // KAlarm calendar format version
40};
41
42CompatibilityAttribute::CompatibilityAttribute()
43 : d(new Private)
44{
45}
46
47CompatibilityAttribute::CompatibilityAttribute(const CompatibilityAttribute& rhs)
48 : Akonadi::Attribute(rhs),
49 d(new Private(*rhs.d))
50{
51}
52
53CompatibilityAttribute::~CompatibilityAttribute()
54{
55 delete d;
56}
57
58CompatibilityAttribute& CompatibilityAttribute::operator=(const CompatibilityAttribute& other)
59{
60 if (&other != this)
61 {
62 Attribute::operator=(other);
63 *d = *other.d;
64 }
65 return *this;
66}
67
68CompatibilityAttribute* CompatibilityAttribute::clone() const
69{
70 return new CompatibilityAttribute(*this);
71}
72
73KACalendar::Compat CompatibilityAttribute::compatibility() const
74{
75 return d->mCompatibility;
76}
77
78void CompatibilityAttribute::setCompatibility(KACalendar::Compat c)
79{
80 d->mCompatibility = c;
81}
82
83int CompatibilityAttribute::version() const
84{
85 return d->mVersion;
86}
87
88void CompatibilityAttribute::setVersion(int v)
89{
90 d->mVersion = v;
91}
92
93QByteArray CompatibilityAttribute::type() const
94{
95 return name();
96}
97
98QByteArray CompatibilityAttribute::name()
99{
100 static const QByteArray attType("KAlarmCompatibility");
101 return attType;
102}
103
104QByteArray CompatibilityAttribute::serialized() const
105{
106 const QByteArray v = QByteArray::number(d->mCompatibility) + ' '
107 + QByteArray::number(d->mVersion);
108 kDebug() << v;
109 return v;
110}
111
112void CompatibilityAttribute::deserialize(const QByteArray& data)
113{
114 kDebug() << data;
115
116 // Set default values
117 d->mCompatibility = KACalendar::Incompatible;
118 d->mVersion = KACalendar::IncompatibleFormat;
119
120 bool ok;
121 const QList<QByteArray> items = data.simplified().split(' ');
122 const int count = items.count();
123 int index = 0;
124 if (count > index)
125 {
126 // 0: calendar format compatibility
127 const int c = items[index++].toInt(&ok);
128 const KACalendar::Compat AllCompat(KACalendar::Current | KACalendar::Converted | KACalendar::Convertible | KACalendar::Incompatible | KACalendar::Unknown);
129 if (!ok || (c & AllCompat) != c)
130 {
131 kError() << "Invalid compatibility:" << c;
132 return;
133 }
134 d->mCompatibility = static_cast<KACalendar::Compat>(c);
135 }
136 if (count > index)
137 {
138 // 1: KAlarm calendar version number
139 const int c = items[index++].toInt(&ok);
140 if (!ok)
141 {
142 kError() << "Invalid version:" << c;
143 return;
144 }
145 d->mVersion = c;
146 }
147}
148
149} // namespace KAlarmCal
150
151// vim: et sw=4:
KAlarmCal::CompatibilityAttribute
An Attribute for a KAlarm Collection containing compatibility information.
Definition: compatibilityattribute.h:48
KAlarmCal::CompatibilityAttribute::operator=
CompatibilityAttribute & operator=(const CompatibilityAttribute &other)
Assignment operator.
Definition: compatibilityattribute.cpp:58
KAlarmCal::CompatibilityAttribute::version
int version() const
Return the KAlarm version of the backend calendar format.
Definition: compatibilityattribute.cpp:83
KAlarmCal::CompatibilityAttribute::type
virtual QByteArray type() const
Reimplemented from Attribute.
Definition: compatibilityattribute.cpp:93
KAlarmCal::CompatibilityAttribute::deserialize
virtual void deserialize(const QByteArray &data)
Reimplemented from Attribute.
Definition: compatibilityattribute.cpp:112
KAlarmCal::CompatibilityAttribute::setCompatibility
void setCompatibility(KACalendar::Compat c)
Set the compatibility status for the entity.
Definition: compatibilityattribute.cpp:78
KAlarmCal::CompatibilityAttribute::setVersion
void setVersion(int v)
Set the KAlarm version of the backend calendar format.
Definition: compatibilityattribute.cpp:88
KAlarmCal::CompatibilityAttribute::clone
virtual CompatibilityAttribute * clone() const
Reimplemented from Attribute.
Definition: compatibilityattribute.cpp:68
KAlarmCal::CompatibilityAttribute::compatibility
KACalendar::Compat compatibility() const
Return the compatibility status for the entity.
Definition: compatibilityattribute.cpp:73
KAlarmCal::CompatibilityAttribute::name
static QByteArray name()
Return the attribute name.
Definition: compatibilityattribute.cpp:98
KAlarmCal::CompatibilityAttribute::CompatibilityAttribute
CompatibilityAttribute()
Default constructor.
Definition: compatibilityattribute.cpp:42
KAlarmCal::CompatibilityAttribute::serialized
virtual QByteArray serialized() const
Reimplemented from Attribute.
Definition: compatibilityattribute.cpp:104
Akonadi
KAlarmCal::KACalendar::IncompatibleFormat
@ IncompatibleFormat
not written by KAlarm, or a newer KAlarm version
Definition: kacalendar.h:101
KAlarmCal::KACalendar::Incompatible
@ Incompatible
not written by KAlarm, or in a newer KAlarm version
Definition: kacalendar.h:77
KAlarmCal::KACalendar::Convertible
@ Convertible
in an older KAlarm format
Definition: kacalendar.h:76
KAlarmCal::KACalendar::Unknown
@ Unknown
format not determined
Definition: kacalendar.h:73
KAlarmCal::KACalendar::Converted
@ Converted
in current KAlarm format, but not yet saved
Definition: kacalendar.h:75
KAlarmCal::KACalendar::Current
@ Current
in current KAlarm format
Definition: kacalendar.h:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KAlarm Library

Skip menu "KAlarm Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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
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