libkcal Library API Documentation

calformat.cpp

00001 /*
00002     This file is part of libkcal.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <klocale.h>
00022 #include <kdebug.h>
00023 #include <kapplication.h>
00024 
00025 #include "calformat.h"
00026 
00027 using namespace KCal;
00028 
00029 QString CalFormat::mApplication = QString::fromLatin1("libkcal");
00030 QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.2//EN");
00031 
00032 // An array containing the PRODID strings indexed against the calendar file format version used.
00033 // Every time the calendar file format is changed, add an entry/entries to this list.
00034 struct CalVersion {
00035   int       version;
00036   QString   prodId;
00037 };
00038 static CalVersion prodIds[] = {
00039   { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") },
00040   { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") },
00041   { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") },
00042   { 320, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.2//EN") },
00043   { 0 , QString() }
00044 };
00045 
00046 
00047 CalFormat::CalFormat()
00048 {
00049   mException = 0;
00050 }
00051 
00052 CalFormat::~CalFormat()
00053 {
00054   delete mException;
00055 }
00056 
00057 void CalFormat::clearException()
00058 {
00059   delete mException;
00060   mException = 0;
00061 }
00062 
00063 void CalFormat::setException(ErrorFormat *exception)
00064 {
00065   delete mException;
00066   mException = exception;
00067 }
00068 
00069 ErrorFormat *CalFormat::exception()
00070 {
00071   return mException;
00072 }
00073 
00074 void CalFormat::setApplication(const QString& application, const QString& productID)
00075 {
00076   mApplication = application;
00077   mProductId = productID;
00078 }
00079 
00080 QString CalFormat::createUniqueId()
00081 {
00082   int hashTime = QTime::currentTime().hour() +
00083                  QTime::currentTime().minute() + QTime::currentTime().second() +
00084                  QTime::currentTime().msec();
00085   QString uidStr = QString("%1-%2.%3")
00086                            .arg(mApplication)
00087                            .arg(KApplication::random())
00088                            .arg(hashTime);
00089   return uidStr;
00090 }
00091 
00092 int CalFormat::calendarVersion(const char* prodId)
00093 {
00094   for (const CalVersion* cv = prodIds;  cv->version;  ++cv) {
00095     if (!strcmp(prodId, cv->prodId.utf8()))
00096       return cv->version;
00097   }
00098   return 0;
00099 }
KDE Logo
This file is part of the documentation for libkcal Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:21 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003