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

KCalCore Library

  • kcalcore
calformat.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 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
32 #include <config-kcalcore.h>
33 #include "calformat.h"
34 #include "exceptions.h"
35 
36 #if defined(HAVE_UUID_UUID_H)
37 #include <uuid/uuid.h>
38 #else
39 #include <KRandom>
40 #include <QtCore/QDateTime>
41 #endif
42 
43 using namespace KCalCore;
44 
49 //@cond PRIVATE
50 class KCalCore::CalFormat::Private
51 {
52  public:
53  Private() : mException( 0 ) {}
54  ~Private() { delete mException; }
55  static QString mApplication; // Name of application, for creating unique ID strings
56  static QString mProductId; // PRODID string to write to calendar files
57  QString mLoadedProductId; // PRODID string loaded from calendar file
58  Exception *mException;
59 };
60 
61 QString CalFormat::Private::mApplication = QLatin1String( "libkcal" );
62 QString CalFormat::Private::mProductId =
63  QLatin1String( "-//K Desktop Environment//NONSGML libkcal 4.3//EN" );
64 //@endcond
65 
66 CalFormat::CalFormat()
67  : d( new KCalCore::CalFormat::Private )
68 {
69 }
70 
71 CalFormat::~CalFormat()
72 {
73  clearException();
74  delete d;
75 }
76 
77 void CalFormat::clearException()
78 {
79  delete d->mException;
80  d->mException = 0;
81 }
82 
83 void CalFormat::setException( Exception *exception )
84 {
85  delete d->mException;
86  d->mException = exception;
87 }
88 
89 Exception *CalFormat::exception() const
90 {
91  return d->mException;
92 }
93 
94 void CalFormat::setApplication( const QString &application,
95  const QString &productID )
96 {
97  Private::mApplication = application;
98  Private::mProductId = productID;
99 }
100 
101 const QString &CalFormat::application()
102 {
103  return Private::mApplication;
104 }
105 
106 const QString &CalFormat::productId()
107 {
108  return Private::mProductId;
109 }
110 
111 QString CalFormat::loadedProductId()
112 {
113  return d->mLoadedProductId;
114 }
115 
116 void CalFormat::setLoadedProductId( const QString &id )
117 {
118  d->mLoadedProductId = id;
119 }
120 
121 QString CalFormat::createUniqueId()
122 {
123 #if defined(HAVE_UUID_UUID_H)
124  uuid_t uuid;
125  char suuid[64];
126 
127  uuid_generate_random( uuid );
128  uuid_unparse( uuid, suuid );
129  return QString( suuid );
130 #else
131  int hashTime = QTime::currentTime().hour() +
132  QTime::currentTime().minute() + QTime::currentTime().second() +
133  QTime::currentTime().msec();
134  QString uidStr = QString( "%1-%2.%3" ).
135  arg( Private::mApplication ).
136  arg( KRandom::random() ).
137  arg( hashTime );
138  return uidStr;
139 #endif
140 }
141 
142 void CalFormat::virtual_hook( int id, void *data )
143 {
144  Q_UNUSED( id );
145  Q_UNUSED( data );
146  Q_ASSERT( false );
147 }
KCalCore::Exception
Exception base class, currently used as a fancy kind of error code and not as an C++ exception...
Definition: exceptions.h:50
KCalCore::CalFormat::productId
static const QString & productId()
Returns the our library&#39;s PRODID string to write into calendar files.
Definition: calformat.cpp:106
KCalCore::CalFormat::setException
void setException(Exception *error)
Sets an exception that is to be used by the functions of this class to report errors.
Definition: calformat.cpp:83
KCalCore::CalFormat::clearException
void clearException()
Clears the exception status.
Definition: calformat.cpp:77
KCalCore::CalFormat::CalFormat
CalFormat()
Constructs a new Calendar Format object.
Definition: calformat.cpp:66
KCalCore::CalFormat::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition: calformat.cpp:142
KCalCore::CalFormat::setApplication
static void setApplication(const QString &application, const QString &productID)
Sets the application name for use in unique IDs and error messages, and product ID for incidence PROD...
Definition: calformat.cpp:94
KCalCore::CalFormat
An abstract base class that provides an interface to various calendar formats.
Definition: calformat.h:48
KCalCore::CalFormat::createUniqueId
static QString createUniqueId()
Creates a unique id string.
Definition: calformat.cpp:121
calformat.h
This file is part of the API for handling calendar data and defines the CalFormat abstract base class...
exceptions.h
This file is part of the API for handling calendar data and defines the Exception class...
KCalCore::CalFormat::loadedProductId
QString loadedProductId()
Returns the PRODID string loaded from calendar file.
Definition: calformat.cpp:111
KCalCore::CalFormat::setLoadedProductId
void setLoadedProductId(const QString &id)
Sets the PRODID string loaded from calendar file.
Definition: calformat.cpp:116
KCalCore::CalFormat::exception
Exception * exception() const
Returns an exception, if there is any, containing information about the last error that occurred...
Definition: calformat.cpp:89
KCalCore::CalFormat::~CalFormat
virtual ~CalFormat()
Destructor.
Definition: calformat.cpp:71
KCalCore::CalFormat::application
static const QString & application()
Returns the application name used in unique IDs and error messages.
Definition: calformat.cpp:101
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:02:04 by doxygen 1.8.5 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-4.11.3 API Reference

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