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

KCalCore Library

calformat.cpp
Go to the documentation of this file.
00001 /*
00002   This file is part of the kcalcore library.
00003 
00004   Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015 
00016   You should have received a copy of the GNU Library General Public License
00017   along with this library; see the file COPYING.LIB.  If not, write to
00018   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019   Boston, MA 02110-1301, USA.
00020 */
00032 #include <config-kcalcore.h>
00033 #include "calformat.h"
00034 #include "exceptions.h"
00035 
00036 #if defined(HAVE_UUID_UUID_H)
00037 #include <uuid/uuid.h>
00038 #else
00039 #include <KRandom>
00040 #include <QtCore/QDateTime>
00041 #endif
00042 
00043 using namespace KCalCore;
00044 
00049 //@cond PRIVATE
00050 class KCalCore::CalFormat::Private
00051 {
00052   public:
00053     Private() : mException( 0 ) {}
00054     ~Private() { delete mException; }
00055     static QString mApplication; // Name of application, for creating unique ID strings
00056     static QString mProductId;   // PRODID string to write to calendar files
00057     QString mLoadedProductId;    // PRODID string loaded from calendar file
00058     Exception *mException;
00059 };
00060 
00061 QString CalFormat::Private::mApplication = QLatin1String( "libkcal" );
00062 QString CalFormat::Private::mProductId =
00063   QLatin1String( "-//K Desktop Environment//NONSGML libkcal 4.3//EN" );
00064 //@endcond
00065 
00066 CalFormat::CalFormat()
00067   : d( new KCalCore::CalFormat::Private )
00068 {
00069 }
00070 
00071 CalFormat::~CalFormat()
00072 {
00073   clearException();
00074   delete d;
00075 }
00076 
00077 void CalFormat::clearException()
00078 {
00079   delete d->mException;
00080   d->mException = 0;
00081 }
00082 
00083 void CalFormat::setException( Exception *exception )
00084 {
00085   delete d->mException;
00086   d->mException = exception;
00087 }
00088 
00089 Exception *CalFormat::exception() const
00090 {
00091   return d->mException;
00092 }
00093 
00094 void CalFormat::setApplication( const QString &application,
00095                                 const QString &productID )
00096 {
00097   Private::mApplication = application;
00098   Private::mProductId = productID;
00099 }
00100 
00101 const QString &CalFormat::application()
00102 {
00103   return Private::mApplication;
00104 }
00105 
00106 const QString &CalFormat::productId()
00107 {
00108   return Private::mProductId;
00109 }
00110 
00111 QString CalFormat::loadedProductId()
00112 {
00113   return d->mLoadedProductId;
00114 }
00115 
00116 void CalFormat::setLoadedProductId( const QString &id )
00117 {
00118   d->mLoadedProductId = id;
00119 }
00120 
00121 QString CalFormat::createUniqueId()
00122 {
00123 #if defined(HAVE_UUID_UUID_H)
00124   uuid_t uuid;
00125   char suuid[64];
00126 
00127   uuid_generate_random( uuid );
00128   uuid_unparse( uuid, suuid );
00129   return QString( suuid );
00130 #else
00131   int hashTime = QTime::currentTime().hour() +
00132                  QTime::currentTime().minute() + QTime::currentTime().second() +
00133                  QTime::currentTime().msec();
00134   QString uidStr = QString( "%1-%2.%3" ).
00135                    arg( Private::mApplication ).
00136                    arg( KRandom::random() ).
00137                    arg( hashTime );
00138   return uidStr;
00139 #endif
00140 }
00141 
00142 void CalFormat::virtual_hook( int id, void *data )
00143 {
00144   Q_UNUSED( id );
00145   Q_UNUSED( data );
00146   Q_ASSERT( false );
00147 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:21 by doxygen 1.8.0 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.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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