summaryrefslogtreecommitdiffabout
path: root/libkcal/calformat.cpp
Unidiff
Diffstat (limited to 'libkcal/calformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calformat.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/libkcal/calformat.cpp b/libkcal/calformat.cpp
index 8a3d069..359f65f 100644
--- a/libkcal/calformat.cpp
+++ b/libkcal/calformat.cpp
@@ -5,94 +5,90 @@
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <klocale.h> 21#include <klocale.h>
22#include <kdebug.h> 22#include <kdebug.h>
23#include <kapplication.h> 23#include <kapplication.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27using namespace KCal; 27using namespace KCal;
28 28
29QString CalFormat::mApplication = QString::fromLatin1("libkcal"); 29QString CalFormat::mApplication = QString::fromLatin1("libkcal-pi");
30QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.1//EN"); 30QString CalFormat::mProductId = QString::fromLatin1("-//KDE-Pim//Platform-independent 2.1.0");
31 31
32// An array containing the PRODID strings indexed against the calendar file format version used. 32// An array containing the PRODID strings indexed against the calendar file format version used.
33// Every time the calendar file format is changed, add an entry/entries to this list. 33// Every time the calendar file format is changed, add an entry/entries to this list.
34struct CalVersion { 34struct CalVersion {
35 int version; 35 int version;
36 QString prodId; 36 QString prodId;
37}; 37};
38static CalVersion prodIds[] = { 38static CalVersion prodIds[] = {
39 { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") }, 39 { 220, QString::fromLatin1("-//KDE-Pim//Pi 2.2//EN") },
40 { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") }, 40 { 300, QString::fromLatin1("-//KDE-Pim//Pi 3.0//EN") },
41 { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") }, 41 { 310, QString::fromLatin1("-//KDE-Pim//Pi 3.1//EN") },
42 { 0 , QString() } 42 { 0 , QString() }
43}; 43};
44 44
45 45
46CalFormat::CalFormat() 46CalFormat::CalFormat()
47{ 47{
48 mException = 0; 48 mException = 0;
49} 49}
50 50
51CalFormat::~CalFormat() 51CalFormat::~CalFormat()
52{ 52{
53 delete mException; 53 delete mException;
54} 54}
55 55
56void CalFormat::clearException() 56void CalFormat::clearException()
57{ 57{
58 delete mException; 58 delete mException;
59 mException = 0; 59 mException = 0;
60} 60}
61 61
62void CalFormat::setException(ErrorFormat *exception) 62void CalFormat::setException(ErrorFormat *exception)
63{ 63{
64 delete mException; 64 delete mException;
65 mException = exception; 65 mException = exception;
66} 66}
67 67
68ErrorFormat *CalFormat::exception() 68ErrorFormat *CalFormat::exception()
69{ 69{
70 return mException; 70 return mException;
71} 71}
72 72
73void CalFormat::setApplication(const QString& application, const QString& productID) 73void CalFormat::setApplication(const QString& application, const QString& productID)
74{ 74{
75 mApplication = application; 75 mApplication = application;
76 mProductId = productID; 76 mProductId = productID;
77} 77}
78 78
79QString CalFormat::createUniqueId() 79QString CalFormat::createUniqueId()
80{ 80{
81 int hashTime = QTime::currentTime().hour() + 81 return QString("%1-%2-%3")
82 QTime::currentTime().minute() + QTime::currentTime().second() + 82 .arg("kopi")
83 QTime::currentTime().msec();
84 QString uidStr = QString("%1-%2.%3")
85 .arg(mApplication)
86 .arg(KApplication::random()) 83 .arg(KApplication::random())
87 .arg(hashTime); 84 .arg(QTime::currentTime().msec()+1);
88 return uidStr;
89} 85}
90 86
91int CalFormat::calendarVersion(const char* prodId) 87int CalFormat::calendarVersion(const char* prodId)
92{ 88{
93 for (const CalVersion* cv = prodIds; cv->version; ++cv) { 89 for (const CalVersion* cv = prodIds; cv->version; ++cv) {
94 if (!strcmp(prodId, cv->prodId.local8Bit())) 90 if (!strcmp(prodId, cv->prodId.local8Bit()))
95 return cv->version; 91 return cv->version;
96 } 92 }
97 return 0; 93 return 0;
98} 94}