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.1//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   { 0 , QString() }
00043 };
00044 
00045 
00046 CalFormat::CalFormat()
00047 {
00048   mException = 0;
00049 }
00050 
00051 CalFormat::~CalFormat()
00052 {
00053   delete mException;
00054 }
00055 
00056 void CalFormat::clearException()
00057 {
00058   delete mException;
00059   mException = 0;
00060 }
00061 
00062 void CalFormat::setException(ErrorFormat *exception)
00063 {
00064   delete mException;
00065   mException = exception;
00066 }
00067 
00068 ErrorFormat *CalFormat::exception()
00069 {
00070   return mException;
00071 }
00072 
00073 void CalFormat::setApplication(const QString& application, const QString& productID)
00074 {
00075   mApplication = application;
00076   mProductId = productID;
00077 }
00078 
00079 QString CalFormat::createUniqueId()
00080 {
00081   int hashTime = QTime::currentTime().hour() +
00082                  QTime::currentTime().minute() + QTime::currentTime().second() +
00083                  QTime::currentTime().msec();
00084   QString uidStr = QString("%1-%2.%3")
00085                            .arg(mApplication)
00086                            .arg(KApplication::random())
00087                            .arg(hashTime);
00088   return uidStr;
00089 }
00090 
00091 int CalFormat::calendarVersion(const char* prodId)
00092 {
00093   for (const CalVersion* cv = prodIds;  cv->version;  ++cv) {
00094     if (!strcmp(prodId, cv->prodId.local8Bit()))
00095       return cv->version;
00096   }
00097   return 0;
00098 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:03 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001