author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /libkcal/calformat.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | libkcal/calformat.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/libkcal/calformat.cpp b/libkcal/calformat.cpp new file mode 100644 index 0000000..8a3d069 --- a/dev/null +++ b/libkcal/calformat.cpp | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | This file is part of libkcal. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <klocale.h> | ||
22 | #include <kdebug.h> | ||
23 | #include <kapplication.h> | ||
24 | |||
25 | #include "calformat.h" | ||
26 | |||
27 | using namespace KCal; | ||
28 | |||
29 | QString CalFormat::mApplication = QString::fromLatin1("libkcal"); | ||
30 | QString CalFormat::mProductId = QString::fromLatin1("-//K Desktop Environment//NONSGML libkcal 3.1//EN"); | ||
31 | |||
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. | ||
34 | struct CalVersion { | ||
35 | int version; | ||
36 | QString prodId; | ||
37 | }; | ||
38 | static CalVersion prodIds[] = { | ||
39 | { 220, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 2.2//EN") }, | ||
40 | { 300, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.0//EN") }, | ||
41 | { 310, QString::fromLatin1("-//K Desktop Environment//NONSGML KOrganizer 3.1//EN") }, | ||
42 | { 0 , QString() } | ||
43 | }; | ||
44 | |||
45 | |||
46 | CalFormat::CalFormat() | ||
47 | { | ||
48 | mException = 0; | ||
49 | } | ||
50 | |||
51 | CalFormat::~CalFormat() | ||
52 | { | ||
53 | delete mException; | ||
54 | } | ||
55 | |||
56 | void CalFormat::clearException() | ||
57 | { | ||
58 | delete mException; | ||
59 | mException = 0; | ||
60 | } | ||
61 | |||
62 | void CalFormat::setException(ErrorFormat *exception) | ||
63 | { | ||
64 | delete mException; | ||
65 | mException = exception; | ||
66 | } | ||
67 | |||
68 | ErrorFormat *CalFormat::exception() | ||
69 | { | ||
70 | return mException; | ||
71 | } | ||
72 | |||
73 | void CalFormat::setApplication(const QString& application, const QString& productID) | ||
74 | { | ||
75 | mApplication = application; | ||
76 | mProductId = productID; | ||
77 | } | ||
78 | |||
79 | QString CalFormat::createUniqueId() | ||
80 | { | ||
81 | int hashTime = QTime::currentTime().hour() + | ||
82 | QTime::currentTime().minute() + QTime::currentTime().second() + | ||
83 | QTime::currentTime().msec(); | ||
84 | QString uidStr = QString("%1-%2.%3") | ||
85 | .arg(mApplication) | ||
86 | .arg(KApplication::random()) | ||
87 | .arg(hashTime); | ||
88 | return uidStr; | ||
89 | } | ||
90 | |||
91 | int CalFormat::calendarVersion(const char* prodId) | ||
92 | { | ||
93 | for (const CalVersion* cv = prodIds; cv->version; ++cv) { | ||
94 | if (!strcmp(prodId, cv->prodId.local8Bit())) | ||
95 | return cv->version; | ||
96 | } | ||
97 | return 0; | ||
98 | } | ||