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

KCalCore Library

  • sources
  • kde-4.14
  • kdepimlibs
  • kcalcore
attendee.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
6  Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public 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
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
34 #include "attendee.h"
35 
36 #include <QDataStream>
37 
38 using namespace KCalCore;
39 
44 //@cond PRIVATE
45 class KCalCore::Attendee::Private
46 {
47 public:
48  void setCuType(CuType cuType);
49  void setCuType(const QString &cuType);
50  CuType cuType() const;
51  QString cuTypeStr() const;
52 
53  bool mRSVP;
54  Role mRole;
55  PartStat mStatus;
56  QString mUid;
57  QString mDelegate;
58  QString mDelegator;
59  CustomProperties mCustomProperties;
60 private:
61  QString sCuType;
62  CuType mCuType;
63 };
64 //@endcond
65 
66 void KCalCore::Attendee::Private::setCuType(Attendee::CuType cuType)
67 {
68  mCuType = cuType;
69  sCuType.clear();
70 }
71 
72 void KCalCore::Attendee::Private::setCuType(const QString &cuType)
73 {
74  const QString upper = cuType.toUpper();
75  if (upper == QLatin1String("INDIVIDUAL")) {
76  setCuType(Attendee::Individual);
77  } else if (upper == QLatin1String("GROUP")) {
78  setCuType(Attendee::Group);
79  } else if (upper == QLatin1String("RESOURCE")) {
80  setCuType(Attendee::Resource);
81  } else if (upper == QLatin1String("ROOM")) {
82  setCuType(Attendee::Room);
83  } else {
84  setCuType(Attendee::Unknown);
85  if (upper.startsWith(QLatin1String("X-")) || upper.startsWith(QLatin1String("IANA-"))) {
86  sCuType = upper;
87  }
88  }
89 }
90 
91 Attendee::CuType KCalCore::Attendee::Private::cuType() const
92 {
93  return mCuType;
94 }
95 
96 QString KCalCore::Attendee::Private::cuTypeStr() const
97 {
98  switch (mCuType) {
99  case Attendee::Individual:
100  return QLatin1String("INDIVIDUAL");
101  case Attendee::Group:
102  return QLatin1String("GROUP");
103  case Attendee::Resource:
104  return QLatin1String("RESOURCE");
105  case Attendee::Room:
106  return QLatin1String("ROOM");
107  case Attendee::Unknown:
108  if (sCuType.isEmpty()) {
109  return QLatin1String("UNKNOWN");
110  } else {
111  return sCuType;
112  }
113  }
114  return QLatin1String("UNKNOWN");
115 }
116 
117 
118 
119 Attendee::Attendee(const QString &name, const QString &email, bool rsvp,
120  Attendee::PartStat status, Attendee::Role role, const QString &uid)
121  : d(new Attendee::Private)
122 {
123  setName(name);
124  setEmail(email);
125  d->mRSVP = rsvp;
126  d->mStatus = status;
127  d->mRole = role;
128  d->mUid = uid;
129  d->setCuType(Attendee::Individual);
130 }
131 
132 Attendee::Attendee(const Attendee &attendee)
133  : Person(attendee),
134  d(new Attendee::Private(*attendee.d))
135 {
136 }
137 
138 Attendee::~Attendee()
139 {
140  delete d;
141 }
142 
143 bool KCalCore::Attendee::operator==(const Attendee &attendee) const
144 {
145  return
146  d->mUid == attendee.d->mUid &&
147  d->mRSVP == attendee.d->mRSVP &&
148  d->mRole == attendee.d->mRole &&
149  d->mStatus == attendee.d->mStatus &&
150  d->mDelegate == attendee.d->mDelegate &&
151  d->mDelegator == attendee.d->mDelegator &&
152  d->cuTypeStr() == attendee.d->cuTypeStr() &&
153  (const Person &)*this == (const Person &)attendee;
154 }
155 
156 bool KCalCore::Attendee::operator!=(const Attendee &attendee) const
157 {
158  return !operator==(attendee);
159 }
160 
161 Attendee &KCalCore::Attendee::operator=(const Attendee &attendee)
162 {
163  // check for self assignment
164  if (&attendee == this) {
165  return *this;
166  }
167 
168  *d = *attendee.d;
169  setName(attendee.name());
170  setEmail(attendee.email());
171  return *this;
172 }
173 
174 void Attendee::setRSVP(bool r)
175 {
176  d->mRSVP = r;
177 }
178 
179 bool Attendee::RSVP() const
180 {
181  return d->mRSVP;
182 }
183 
184 void Attendee::setStatus(Attendee::PartStat status)
185 {
186  d->mStatus = status;
187 }
188 
189 Attendee::PartStat Attendee::status() const
190 {
191  return d->mStatus;
192 }
193 
194 void Attendee::setCuType(Attendee::CuType cuType)
195 {
196  d->setCuType(cuType);
197 }
198 
199 void Attendee::setCuType(const QString &cuType)
200 {
201  d->setCuType(cuType);
202 }
203 
204 Attendee::CuType Attendee::cuType() const
205 {
206  return d->cuType();
207 }
208 
209 QString Attendee::cuTypeStr() const
210 {
211  return d->cuTypeStr();
212 }
213 
214 void Attendee::setRole(Attendee::Role role)
215 {
216  d->mRole = role;
217 }
218 
219 Attendee::Role Attendee::role() const
220 {
221  return d->mRole;
222 }
223 
224 void Attendee::setUid(const QString &uid)
225 {
226  d->mUid = uid;
227 }
228 
229 QString Attendee::uid() const
230 {
231  return d->mUid;
232 }
233 
234 void Attendee::setDelegate(const QString &delegate)
235 {
236  d->mDelegate = delegate;
237 }
238 
239 QString Attendee::delegate() const
240 {
241  return d->mDelegate;
242 }
243 
244 void Attendee::setDelegator(const QString &delegator)
245 {
246  d->mDelegator = delegator;
247 }
248 
249 QString Attendee::delegator() const
250 {
251  return d->mDelegator;
252 }
253 
254 void Attendee::setCustomProperty(const QByteArray &xname, const QString &xvalue)
255 {
256  d->mCustomProperties.setNonKDECustomProperty(xname, xvalue);
257 }
258 
259 CustomProperties &Attendee::customProperties()
260 {
261  return d->mCustomProperties;
262 }
263 
264 const CustomProperties &Attendee::customProperties() const
265 {
266  return d->mCustomProperties;
267 }
268 
269 QDataStream &KCalCore::operator<<(QDataStream &stream, const KCalCore::Attendee::Ptr &attendee)
270 {
271  KCalCore::Person::Ptr p(new KCalCore::Person(*((Person *)attendee.data())));
272  stream << p;
273  return stream << attendee->d->mRSVP
274  << int(attendee->d->mRole)
275  << int(attendee->d->mStatus)
276  << attendee->d->mUid
277  << attendee->d->mDelegate
278  << attendee->d->mDelegator
279  << attendee->d->cuTypeStr()
280  << attendee->d->mCustomProperties;
281 }
282 
283 QDataStream &KCalCore::operator>>(QDataStream &stream, KCalCore::Attendee::Ptr &attendee)
284 {
285  bool RSVP;
286  Attendee::Role role;
287  Attendee::PartStat status;
288  QString uid;
289  QString delegate;
290  QString delegator;
291  QString cuType;
292  CustomProperties customProperties;
293  uint role_int;
294  uint status_int;
295 
296  KCalCore::Person::Ptr person(new Person());
297  stream >> person;
298  stream >> RSVP
299  >> role_int
300  >> status_int
301  >> uid
302  >> delegate
303  >> delegator
304  >> cuType
305  >> customProperties;
306 
307  role = Attendee::Role(role_int);
308  status = Attendee::PartStat(status_int);
309 
310  Attendee::Ptr att_temp(new KCalCore::Attendee(person->name(), person->email(),
311  RSVP, status, role, uid));
312  att_temp->setDelegate(delegate);
313  att_temp->setDelegator(delegator);
314  att_temp->setCuType(cuType);
315  att_temp->d->mCustomProperties = customProperties;
316  attendee.swap(att_temp);
317  return stream;
318 }
KCalCore::Attendee::setDelegator
void setDelegator(const QString &delegator)
Sets the delegator.
Definition: attendee.cpp:244
KCalCore::Attendee::~Attendee
~Attendee()
Destroys the attendee.
Definition: attendee.cpp:138
KCalCore::Attendee::setStatus
void setStatus(PartStat status)
Sets the PartStat of the attendee to status.
Definition: attendee.cpp:184
attendee.h
This file is part of the API for handling calendar data and defines the Attendee class.
QString::toUpper
QString toUpper() const
KCalCore::Attendee::cuType
CuType cuType() const
Returns the CuType of the attendee.
Definition: attendee.cpp:204
KCalCore::Person
Represents a person, by name and email address.
Definition: person.h:50
KCalCore::Attendee::Individual
An individual (default)
Definition: attendee.h:98
KCalCore::Attendee::Group
A group of individuals.
Definition: attendee.h:99
QByteArray
KCalCore::Attendee::Attendee
Attendee(const QString &name, const QString &email, bool rsvp=false, PartStat status=None, Role role=ReqParticipant, const QString &uid=QString())
Constructs an attendee consisting of a Person name (name) and email address (email); invitation statu...
Definition: attendee.cpp:119
QDataStream
KCalCore::Person::setEmail
void setEmail(const QString &email)
Sets the email address for this person to email.
Definition: person.cpp:146
KCalCore::Attendee::delegate
QString delegate() const
Returns the delegate.
Definition: attendee.cpp:239
KCalCore::Person::name
QString name() const
Returns the person name string.
Definition: person.cpp:126
KCalCore::Attendee::setCustomProperty
void setCustomProperty(const QByteArray &xname, const QString &xvalue)
Adds a custom property.
Definition: attendee.cpp:254
KCalCore::Attendee::Role
Role
The different types of participation roles.
Definition: attendee.h:84
KCalCore::Attendee::setUid
void setUid(const QString &uid)
Sets the UID of the attendee to uid.
Definition: attendee.cpp:224
KCalCore::Attendee::setCuType
void setCuType(CuType cuType)
Sets the CuType of the attendee to cuType.
Definition: attendee.cpp:194
KCalCore::Attendee::RSVP
bool RSVP() const
Returns the attendee RSVP flag.
Definition: attendee.cpp:179
QSharedPointer::data
T * data() const
KCalCore::Attendee::Unknown
Otherwise not known.
Definition: attendee.h:102
KCalCore::Attendee::operator=
Attendee & operator=(const Attendee &attendee)
Sets this attendee equal to attendee.
Definition: attendee.cpp:161
KCalCore::Person::setName
void setName(const QString &name)
Sets the name of the person to name.
Definition: person.cpp:141
KCalCore::Attendee::CuType
CuType
The different types of a participant.
Definition: attendee.h:97
QSharedPointer
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
KCalCore::Attendee::setDelegate
void setDelegate(const QString &delegate)
Sets the delegate.
Definition: attendee.cpp:234
KCalCore::Attendee::status
PartStat status() const
Returns the PartStat of the attendee.
Definition: attendee.cpp:189
KCalCore::Attendee::PartStat
PartStat
The different types of participant status.
Definition: attendee.h:70
KCalCore::Attendee::setRSVP
void setRSVP(bool rsvp)
Sets the RSVP flag of the attendee to rsvp.
Definition: attendee.cpp:174
QString
KCalCore::Attendee::uid
QString uid() const
Returns the UID of the attendee.
Definition: attendee.cpp:229
KCalCore::Person::email
QString email() const
Returns the email address for this person.
Definition: person.cpp:131
KCalCore::operator>>
KCALCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:863
KCalCore::Attendee::cuTypeStr
QString cuTypeStr() const
Returns the CuType of the attendee.
Definition: attendee.cpp:209
KCalCore::CustomProperties
A class to manage custom calendar properties.
Definition: customproperties.h:51
KCalCore::Attendee::operator!=
bool operator!=(const Attendee &attendee) const
Compares this with attendee for inequality.
Definition: attendee.cpp:156
QLatin1String
KCalCore::Attendee::role
Role role() const
Returns the Role of the attendee.
Definition: attendee.cpp:219
KCalCore::Attendee::operator==
bool operator==(const Attendee &attendee) const
Compares this with attendee for equality.
Definition: attendee.cpp:143
KCalCore::Attendee::customProperties
CustomProperties & customProperties()
Returns a reference to the CustomProperties object.
Definition: attendee.cpp:259
KCalCore::Attendee::Room
A room resource.
Definition: attendee.h:101
KCalCore::Attendee::delegator
QString delegator() const
Returns the delegator.
Definition: attendee.cpp:249
KCalCore::Attendee
Represents information related to an attendee of an Calendar Incidence, typically a meeting or task (...
Definition: attendee.h:57
KCalCore::Attendee::Resource
A physical resource.
Definition: attendee.h:100
KCalCore::operator<<
KCALCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:853
KCalCore::Attendee::setRole
void setRole(Role role)
Sets the Role of the attendee to role.
Definition: attendee.cpp:214
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:36:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCalCore Library

Skip menu "KCalCore Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • 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