author | zautrix <zautrix> | 2004-10-05 08:07:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 08:07:41 (UTC) |
commit | ad859d26b813101adab963f50e694961702561d9 (patch) (unidiff) | |
tree | 36eb7f12ee6ee80f50cdd13bbfaba74e9a1b37d1 /libkcal | |
parent | fc2c103f45a6d4e4105259436266538c645f2c87 (diff) | |
download | kdepimpi-ad859d26b813101adab963f50e694961702561d9.zip kdepimpi-ad859d26b813101adab963f50e694961702561d9.tar.gz kdepimpi-ad859d26b813101adab963f50e694961702561d9.tar.bz2 |
cleanup
-rw-r--r-- | libkcal/calstorage.h | 2 | ||||
-rw-r--r-- | libkcal/filestorage.cpp | 4 | ||||
-rw-r--r-- | libkcal/filestorage.h | 2 | ||||
-rw-r--r-- | libkcal/icalformat.cpp | 24 | ||||
-rw-r--r-- | libkcal/icalformat.h | 3 |
5 files changed, 7 insertions, 28 deletions
diff --git a/libkcal/calstorage.h b/libkcal/calstorage.h index 72972ea..82c8682 100644 --- a/libkcal/calstorage.h +++ b/libkcal/calstorage.h | |||
@@ -1,52 +1,52 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
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 | #ifndef KCAL_CALSTORAGE_H | 20 | #ifndef KCAL_CALSTORAGE_H |
21 | #define KCAL_CALSTORAGE_H | 21 | #define KCAL_CALSTORAGE_H |
22 | 22 | ||
23 | namespace KCal { | 23 | namespace KCal { |
24 | 24 | ||
25 | class Calendar; | 25 | class Calendar; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | This class provides the interface to the storage of a calendar. | 28 | This class provides the interface to the storage of a calendar. |
29 | */ | 29 | */ |
30 | class CalStorage | 30 | class CalStorage |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | CalStorage( Calendar *calendar ) | 33 | CalStorage( Calendar *calendar ) |
34 | { | 34 | { |
35 | mCalendar = calendar; | 35 | mCalendar = calendar; |
36 | } | 36 | } |
37 | virtual ~CalStorage() {} | 37 | virtual ~CalStorage() {} |
38 | 38 | ||
39 | Calendar *calendar() const { return mCalendar; } | 39 | Calendar *calendar() const { return mCalendar; } |
40 | 40 | ||
41 | virtual bool open() = 0; | 41 | virtual bool open() = 0; |
42 | virtual bool load(bool = false ) = 0; | 42 | virtual bool load( ) = 0; |
43 | virtual bool save() = 0; | 43 | virtual bool save() = 0; |
44 | virtual bool close() = 0; | 44 | virtual bool close() = 0; |
45 | 45 | ||
46 | private: | 46 | private: |
47 | Calendar *mCalendar; | 47 | Calendar *mCalendar; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | } | 50 | } |
51 | 51 | ||
52 | #endif | 52 | #endif |
diff --git a/libkcal/filestorage.cpp b/libkcal/filestorage.cpp index 00c15d9..a139124 100644 --- a/libkcal/filestorage.cpp +++ b/libkcal/filestorage.cpp | |||
@@ -1,140 +1,140 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
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 <stdlib.h> | 21 | #include <stdlib.h> |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | 28 | ||
29 | #include "calendar.h" | 29 | #include "calendar.h" |
30 | #include "vcaldrag.h" | 30 | #include "vcaldrag.h" |
31 | #include "vcalformat.h" | 31 | #include "vcalformat.h" |
32 | #include "icalformat.h" | 32 | #include "icalformat.h" |
33 | 33 | ||
34 | #include "filestorage.h" | 34 | #include "filestorage.h" |
35 | 35 | ||
36 | using namespace KCal; | 36 | using namespace KCal; |
37 | 37 | ||
38 | FileStorage::FileStorage( Calendar *cal, const QString &fileName, | 38 | FileStorage::FileStorage( Calendar *cal, const QString &fileName, |
39 | CalFormat *format ) | 39 | CalFormat *format ) |
40 | : CalStorage( cal ), | 40 | : CalStorage( cal ), |
41 | mFileName( fileName ), | 41 | mFileName( fileName ), |
42 | mSaveFormat( format ) | 42 | mSaveFormat( format ) |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | FileStorage::~FileStorage() | 46 | FileStorage::~FileStorage() |
47 | { | 47 | { |
48 | delete mSaveFormat; | 48 | delete mSaveFormat; |
49 | } | 49 | } |
50 | 50 | ||
51 | void FileStorage::setFileName( const QString &fileName ) | 51 | void FileStorage::setFileName( const QString &fileName ) |
52 | { | 52 | { |
53 | mFileName = fileName; | 53 | mFileName = fileName; |
54 | } | 54 | } |
55 | 55 | ||
56 | QString FileStorage::fileName()const | 56 | QString FileStorage::fileName()const |
57 | { | 57 | { |
58 | return mFileName; | 58 | return mFileName; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void FileStorage::setSaveFormat( CalFormat *format ) | 62 | void FileStorage::setSaveFormat( CalFormat *format ) |
63 | { | 63 | { |
64 | delete mSaveFormat; | 64 | delete mSaveFormat; |
65 | mSaveFormat = format; | 65 | mSaveFormat = format; |
66 | } | 66 | } |
67 | 67 | ||
68 | CalFormat *FileStorage::saveFormat()const | 68 | CalFormat *FileStorage::saveFormat()const |
69 | { | 69 | { |
70 | return mSaveFormat; | 70 | return mSaveFormat; |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | bool FileStorage::open() | 74 | bool FileStorage::open() |
75 | { | 75 | { |
76 | return true; | 76 | return true; |
77 | } | 77 | } |
78 | 78 | ||
79 | bool FileStorage::load( bool quick ) | 79 | bool FileStorage::load( ) |
80 | { | 80 | { |
81 | kdDebug(5800) << "FileStorage::load(): '" << mFileName << "'" << endl; | 81 | kdDebug(5800) << "FileStorage::load(): '" << mFileName << "'" << endl; |
82 | 82 | ||
83 | // do we want to silently accept this, or make some noise? Dunno... | 83 | // do we want to silently accept this, or make some noise? Dunno... |
84 | // it is a semantical thing vs. a practical thing. | 84 | // it is a semantical thing vs. a practical thing. |
85 | if (mFileName.isEmpty()) return false; | 85 | if (mFileName.isEmpty()) return false; |
86 | 86 | ||
87 | // Always try to load with iCalendar. It will detect, if it is actually a | 87 | // Always try to load with iCalendar. It will detect, if it is actually a |
88 | // vCalendar file. | 88 | // vCalendar file. |
89 | ICalFormat iCal (quick ); | 89 | ICalFormat iCal; |
90 | 90 | ||
91 | bool success = iCal.load( calendar(), mFileName); | 91 | bool success = iCal.load( calendar(), mFileName); |
92 | 92 | ||
93 | if ( !success ) { | 93 | if ( !success ) { |
94 | if ( iCal.exception() ) { | 94 | if ( iCal.exception() ) { |
95 | // kdDebug(5800) << "---Error: " << mFormat->exception()->errorCode() << endl; | 95 | // kdDebug(5800) << "---Error: " << mFormat->exception()->errorCode() << endl; |
96 | if ( iCal.exception()->errorCode() == ErrorFormat::CalVersion1 ) { | 96 | if ( iCal.exception()->errorCode() == ErrorFormat::CalVersion1 ) { |
97 | // Expected non vCalendar file, but detected vCalendar | 97 | // Expected non vCalendar file, but detected vCalendar |
98 | kdDebug(5800) << "FileStorage::load() Fallback to VCalFormat" << endl; | 98 | kdDebug(5800) << "FileStorage::load() Fallback to VCalFormat" << endl; |
99 | VCalFormat vCal; | 99 | VCalFormat vCal; |
100 | success = vCal.load( calendar(), mFileName ); | 100 | success = vCal.load( calendar(), mFileName ); |
101 | calendar()->setLoadedProductId( vCal.productId() ); | 101 | calendar()->setLoadedProductId( vCal.productId() ); |
102 | } else { | 102 | } else { |
103 | return false; | 103 | return false; |
104 | } | 104 | } |
105 | } else { | 105 | } else { |
106 | kdDebug(5800) << "Warning! There should be set an exception." << endl; | 106 | kdDebug(5800) << "Warning! There should be set an exception." << endl; |
107 | return false; | 107 | return false; |
108 | } | 108 | } |
109 | } else { | 109 | } else { |
110 | // kdDebug(5800) << "---Success" << endl; | 110 | // kdDebug(5800) << "---Success" << endl; |
111 | calendar()->setLoadedProductId( iCal.loadedProductId() ); | 111 | calendar()->setLoadedProductId( iCal.loadedProductId() ); |
112 | } | 112 | } |
113 | 113 | ||
114 | calendar()->setModified( false ); | 114 | calendar()->setModified( false ); |
115 | 115 | ||
116 | return true; | 116 | return true; |
117 | } | 117 | } |
118 | 118 | ||
119 | bool FileStorage::save() | 119 | bool FileStorage::save() |
120 | { | 120 | { |
121 | if ( mFileName.isEmpty() ) return false; | 121 | if ( mFileName.isEmpty() ) return false; |
122 | 122 | ||
123 | bool success; | 123 | bool success; |
124 | 124 | ||
125 | if ( mSaveFormat ) { | 125 | if ( mSaveFormat ) { |
126 | success = mSaveFormat->save( calendar(), mFileName); | 126 | success = mSaveFormat->save( calendar(), mFileName); |
127 | } else { | 127 | } else { |
128 | ICalFormat iCal; | 128 | ICalFormat iCal; |
129 | success = iCal.save( calendar(), mFileName); | 129 | success = iCal.save( calendar(), mFileName); |
130 | } | 130 | } |
131 | 131 | ||
132 | if ( success ) calendar()->setModified( false ); | 132 | if ( success ) calendar()->setModified( false ); |
133 | 133 | ||
134 | return success; | 134 | return success; |
135 | } | 135 | } |
136 | 136 | ||
137 | bool FileStorage::close() | 137 | bool FileStorage::close() |
138 | { | 138 | { |
139 | return true; | 139 | return true; |
140 | } | 140 | } |
diff --git a/libkcal/filestorage.h b/libkcal/filestorage.h index e9dc15e..17010ac 100644 --- a/libkcal/filestorage.h +++ b/libkcal/filestorage.h | |||
@@ -1,58 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
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 | #ifndef KCAL_FILESTORAGE_H | 20 | #ifndef KCAL_FILESTORAGE_H |
21 | #define KCAL_FILESTORAGE_H | 21 | #define KCAL_FILESTORAGE_H |
22 | 22 | ||
23 | #include "calstorage.h" | 23 | #include "calstorage.h" |
24 | 24 | ||
25 | namespace KCal { | 25 | namespace KCal { |
26 | 26 | ||
27 | /** | 27 | /** |
28 | This class provides a calendar storage as a local file. | 28 | This class provides a calendar storage as a local file. |
29 | */ | 29 | */ |
30 | class FileStorage : public CalStorage | 30 | class FileStorage : public CalStorage |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | FileStorage( Calendar *, const QString &fileName = QString::null, | 33 | FileStorage( Calendar *, const QString &fileName = QString::null, |
34 | CalFormat *format = 0 ); | 34 | CalFormat *format = 0 ); |
35 | virtual ~FileStorage(); | 35 | virtual ~FileStorage(); |
36 | 36 | ||
37 | void setFileName( const QString &mFileName ); | 37 | void setFileName( const QString &mFileName ); |
38 | QString fileName()const; | 38 | QString fileName()const; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | FileStorage takes ownership of format object. | 41 | FileStorage takes ownership of format object. |
42 | */ | 42 | */ |
43 | void setSaveFormat( CalFormat * ); | 43 | void setSaveFormat( CalFormat * ); |
44 | CalFormat *saveFormat()const; | 44 | CalFormat *saveFormat()const; |
45 | 45 | ||
46 | bool open(); | 46 | bool open(); |
47 | bool load(bool quick = false ); | 47 | bool load( ); |
48 | bool save(); | 48 | bool save(); |
49 | bool close(); | 49 | bool close(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | QString mFileName; | 52 | QString mFileName; |
53 | CalFormat *mSaveFormat; | 53 | CalFormat *mSaveFormat; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | #endif | 58 | #endif |
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp index f2e7dfc..3a2aac6 100644 --- a/libkcal/icalformat.cpp +++ b/libkcal/icalformat.cpp | |||
@@ -1,480 +1,460 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
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 <qdatetime.h> | 21 | #include <qdatetime.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qptrlist.h> | 23 | #include <qptrlist.h> |
24 | #include <qregexp.h> | 24 | #include <qregexp.h> |
25 | #include <qclipboard.h> | 25 | #include <qclipboard.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qtextstream.h> | 27 | #include <qtextstream.h> |
28 | #include <qtextcodec.h> | 28 | #include <qtextcodec.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | extern "C" { | 35 | extern "C" { |
36 | #include <ical.h> | 36 | #include <ical.h> |
37 | #include <icalss.h> | 37 | #include <icalss.h> |
38 | #include <icalparser.h> | 38 | #include <icalparser.h> |
39 | #include <icalrestriction.h> | 39 | #include <icalrestriction.h> |
40 | } | 40 | } |
41 | 41 | ||
42 | #include "calendar.h" | 42 | #include "calendar.h" |
43 | #include "calendarlocal.h" | 43 | #include "calendarlocal.h" |
44 | #include "journal.h" | 44 | #include "journal.h" |
45 | 45 | ||
46 | #include "icalformat.h" | 46 | #include "icalformat.h" |
47 | #include "icalformatimpl.h" | 47 | #include "icalformatimpl.h" |
48 | 48 | ||
49 | #define _ICAL_VERSION "2.0" | 49 | #define _ICAL_VERSION "2.0" |
50 | 50 | ||
51 | using namespace KCal; | 51 | using namespace KCal; |
52 | 52 | ||
53 | ICalFormat::ICalFormat(bool quick ) | 53 | ICalFormat::ICalFormat( ) |
54 | { | 54 | { |
55 | mQuicksave = false; //quick; | ||
56 | mImpl = new ICalFormatImpl( this ); | 55 | mImpl = new ICalFormatImpl( this ); |
57 | tzOffsetMin = 0; | 56 | tzOffsetMin = 0; |
58 | //qDebug("new ICalFormat() "); | 57 | //qDebug("new ICalFormat() "); |
59 | } | 58 | } |
60 | 59 | ||
61 | ICalFormat::~ICalFormat() | 60 | ICalFormat::~ICalFormat() |
62 | { | 61 | { |
63 | delete mImpl; | 62 | delete mImpl; |
64 | //qDebug("delete ICalFormat "); | 63 | //qDebug("delete ICalFormat "); |
65 | } | 64 | } |
66 | 65 | ||
67 | bool ICalFormat::load( Calendar *calendar, const QString &fileName) | 66 | bool ICalFormat::load( Calendar *calendar, const QString &fileName) |
68 | { | 67 | { |
69 | 68 | ||
70 | clearException(); | 69 | clearException(); |
71 | 70 | ||
72 | QFile file( fileName ); | 71 | QFile file( fileName ); |
73 | if (!file.open( IO_ReadOnly ) ) { | 72 | if (!file.open( IO_ReadOnly ) ) { |
74 | setException(new ErrorFormat(ErrorFormat::LoadError)); | 73 | setException(new ErrorFormat(ErrorFormat::LoadError)); |
75 | return false; | 74 | return false; |
76 | } | 75 | } |
77 | QTextStream ts( &file ); | 76 | QTextStream ts( &file ); |
78 | QString text; | 77 | QString text; |
79 | #if 0 | 78 | |
80 | if ( !mQuicksave ) { | ||
81 | qDebug("KO: No quickload!"); | ||
82 | ts.setEncoding( QTextStream::Latin1 ); | ||
83 | text = ts.read(); | ||
84 | } else { | ||
85 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
86 | text = ts.read(); | ||
87 | } | ||
88 | #endif | ||
89 | ts.setEncoding( QTextStream::Latin1 ); | 79 | ts.setEncoding( QTextStream::Latin1 ); |
90 | text = ts.read(); | 80 | text = ts.read(); |
91 | file.close(); | 81 | file.close(); |
92 | 82 | ||
93 | return fromString( calendar, text ); | 83 | return fromString( calendar, text ); |
94 | } | 84 | } |
95 | 85 | ||
96 | //#include <qdatetime.h> | 86 | //#include <qdatetime.h> |
97 | bool ICalFormat::save( Calendar *calendar, const QString &fileName ) | 87 | bool ICalFormat::save( Calendar *calendar, const QString &fileName ) |
98 | { | 88 | { |
99 | //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl; | 89 | //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl; |
100 | //qDebug("ICalFormat::save "); | 90 | //qDebug("ICalFormat::save "); |
101 | clearException(); | 91 | clearException(); |
102 | QString text = toString( calendar ); | 92 | QString text = toString( calendar ); |
103 | //return false; | 93 | //return false; |
104 | // qDebug("to string takes ms: %d ",is.elapsed() ); | 94 | // qDebug("to string takes ms: %d ",is.elapsed() ); |
105 | if ( text.isNull() ) return false; | 95 | if ( text.isNull() ) return false; |
106 | 96 | ||
107 | // TODO: write backup file | 97 | // TODO: write backup file |
108 | //is.restart(); | 98 | //is.restart(); |
109 | QFile file( fileName ); | 99 | QFile file( fileName ); |
110 | if (!file.open( IO_WriteOnly ) ) { | 100 | if (!file.open( IO_WriteOnly ) ) { |
111 | setException(new ErrorFormat(ErrorFormat::SaveError, | 101 | setException(new ErrorFormat(ErrorFormat::SaveError, |
112 | i18n("Could not open file '%1'").arg(fileName))); | 102 | i18n("Could not open file '%1'").arg(fileName))); |
113 | return false; | 103 | return false; |
114 | } | 104 | } |
115 | QTextStream ts( &file ); | 105 | QTextStream ts( &file ); |
116 | 106 | ||
117 | // #ifdef DESKTOP_VERSION | ||
118 | // mQuicksave = false; | ||
119 | // #endif | ||
120 | // if ( mQuicksave ) { | ||
121 | // ts << text.utf8(); | ||
122 | // } else { | ||
123 | // ts.setEncoding( QTextStream::Latin1 ); | ||
124 | // ts << text; | ||
125 | // //ts << text.latin1(); | ||
126 | // } | ||
127 | ts.setEncoding( QTextStream::Latin1 ); | 107 | ts.setEncoding( QTextStream::Latin1 ); |
128 | ts << text; | 108 | ts << text; |
129 | file.close(); | 109 | file.close(); |
130 | //qDebug("saving file takes ms: %d ", is.elapsed() ); | 110 | //qDebug("saving file takes ms: %d ", is.elapsed() ); |
131 | return true; | 111 | return true; |
132 | } | 112 | } |
133 | 113 | ||
134 | bool ICalFormat::fromString( Calendar *cal, const QString &text ) | 114 | bool ICalFormat::fromString( Calendar *cal, const QString &text ) |
135 | { | 115 | { |
136 | setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); | 116 | setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); |
137 | // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1()); | 117 | // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1()); |
138 | // Get first VCALENDAR component. | 118 | // Get first VCALENDAR component. |
139 | // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components | 119 | // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components |
140 | icalcomponent *calendar; | 120 | icalcomponent *calendar; |
141 | 121 | ||
142 | //calendar = icalcomponent_new_from_string( text.local8Bit().data()); | 122 | //calendar = icalcomponent_new_from_string( text.local8Bit().data()); |
143 | // good calendar = icalcomponent_new_from_string( text.utf8().data()); | 123 | // good calendar = icalcomponent_new_from_string( text.utf8().data()); |
144 | calendar = icalcomponent_new_from_string( (char*)text.latin1()); | 124 | calendar = icalcomponent_new_from_string( (char*)text.latin1()); |
145 | if (!calendar) { | 125 | if (!calendar) { |
146 | setException(new ErrorFormat(ErrorFormat::ParseErrorIcal)); | 126 | setException(new ErrorFormat(ErrorFormat::ParseErrorIcal)); |
147 | return false; | 127 | return false; |
148 | } | 128 | } |
149 | 129 | ||
150 | bool success = true; | 130 | bool success = true; |
151 | 131 | ||
152 | if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) { | 132 | if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) { |
153 | setException(new ErrorFormat(ErrorFormat::NoCalendar)); | 133 | setException(new ErrorFormat(ErrorFormat::NoCalendar)); |
154 | success = false; | 134 | success = false; |
155 | } else { | 135 | } else { |
156 | // put all objects into their proper places | 136 | // put all objects into their proper places |
157 | if ( !mImpl->populate( cal, calendar ) ) { | 137 | if ( !mImpl->populate( cal, calendar ) ) { |
158 | if ( !exception() ) { | 138 | if ( !exception() ) { |
159 | setException(new ErrorFormat(ErrorFormat::ParseErrorKcal)); | 139 | setException(new ErrorFormat(ErrorFormat::ParseErrorKcal)); |
160 | } | 140 | } |
161 | success = false; | 141 | success = false; |
162 | } else | 142 | } else |
163 | mLoadedProductId = mImpl->loadedProductId(); | 143 | mLoadedProductId = mImpl->loadedProductId(); |
164 | } | 144 | } |
165 | 145 | ||
166 | icalcomponent_free( calendar ); | 146 | icalcomponent_free( calendar ); |
167 | 147 | ||
168 | return success; | 148 | return success; |
169 | } | 149 | } |
170 | 150 | ||
171 | Incidence *ICalFormat::fromString( const QString &text ) | 151 | Incidence *ICalFormat::fromString( const QString &text ) |
172 | { | 152 | { |
173 | CalendarLocal cal( mTimeZoneId ); | 153 | CalendarLocal cal( mTimeZoneId ); |
174 | fromString(&cal, text); | 154 | fromString(&cal, text); |
175 | 155 | ||
176 | Incidence *ical = 0; | 156 | Incidence *ical = 0; |
177 | QPtrList<Event> elist = cal.events(); | 157 | QPtrList<Event> elist = cal.events(); |
178 | if ( elist.count() > 0 ) { | 158 | if ( elist.count() > 0 ) { |
179 | ical = elist.first(); | 159 | ical = elist.first(); |
180 | } else { | 160 | } else { |
181 | QPtrList<Todo> tlist = cal.todos(); | 161 | QPtrList<Todo> tlist = cal.todos(); |
182 | if ( tlist.count() > 0 ) { | 162 | if ( tlist.count() > 0 ) { |
183 | ical = tlist.first(); | 163 | ical = tlist.first(); |
184 | } else { | 164 | } else { |
185 | QPtrList<Journal> jlist = cal.journals(); | 165 | QPtrList<Journal> jlist = cal.journals(); |
186 | if ( jlist.count() > 0 ) { | 166 | if ( jlist.count() > 0 ) { |
187 | ical = jlist.first(); | 167 | ical = jlist.first(); |
188 | } | 168 | } |
189 | } | 169 | } |
190 | } | 170 | } |
191 | return ical; | 171 | return ical; |
192 | } | 172 | } |
193 | #include <qapp.h> | 173 | #include <qapp.h> |
194 | 174 | ||
195 | QString ICalFormat::toString( Calendar *cal ) | 175 | QString ICalFormat::toString( Calendar *cal ) |
196 | { | 176 | { |
197 | 177 | ||
198 | setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); | 178 | setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); |
199 | 179 | ||
200 | icalcomponent *calendar = mImpl->createCalendarComponent(cal); | 180 | icalcomponent *calendar = mImpl->createCalendarComponent(cal); |
201 | 181 | ||
202 | icalcomponent *component; | 182 | icalcomponent *component; |
203 | 183 | ||
204 | // todos | 184 | // todos |
205 | QPtrList<Todo> todoList = cal->rawTodos(); | 185 | QPtrList<Todo> todoList = cal->rawTodos(); |
206 | QPtrListIterator<Todo> qlt(todoList); | 186 | QPtrListIterator<Todo> qlt(todoList); |
207 | for (; qlt.current(); ++qlt) { | 187 | for (; qlt.current(); ++qlt) { |
208 | component = mImpl->writeTodo(qlt.current()); | 188 | component = mImpl->writeTodo(qlt.current()); |
209 | icalcomponent_add_component(calendar,component); | 189 | icalcomponent_add_component(calendar,component); |
210 | //qDebug(" todos "); | 190 | //qDebug(" todos "); |
211 | qApp->processEvents(); | 191 | qApp->processEvents(); |
212 | } | 192 | } |
213 | // events | 193 | // events |
214 | QPtrList<Event> events = cal->rawEvents(); | 194 | QPtrList<Event> events = cal->rawEvents(); |
215 | Event *ev; | 195 | Event *ev; |
216 | for(ev=events.first();ev;ev=events.next()) { | 196 | for(ev=events.first();ev;ev=events.next()) { |
217 | component = mImpl->writeEvent(ev); | 197 | component = mImpl->writeEvent(ev); |
218 | icalcomponent_add_component(calendar,component); | 198 | icalcomponent_add_component(calendar,component); |
219 | //qDebug("events "); | 199 | //qDebug("events "); |
220 | qApp->processEvents(); | 200 | qApp->processEvents(); |
221 | } | 201 | } |
222 | 202 | ||
223 | // journals | 203 | // journals |
224 | QPtrList<Journal> journals = cal->journals(); | 204 | QPtrList<Journal> journals = cal->journals(); |
225 | Journal *j; | 205 | Journal *j; |
226 | for(j=journals.first();j;j=journals.next()) { | 206 | for(j=journals.first();j;j=journals.next()) { |
227 | component = mImpl->writeJournal(j); | 207 | component = mImpl->writeJournal(j); |
228 | icalcomponent_add_component(calendar,component); | 208 | icalcomponent_add_component(calendar,component); |
229 | //qDebug("journals "); | 209 | //qDebug("journals "); |
230 | qApp->processEvents(); | 210 | qApp->processEvents(); |
231 | } | 211 | } |
232 | const char *text; | 212 | const char *text; |
233 | QString ret =""; | 213 | QString ret =""; |
234 | text = icalcomponent_as_ical_string( calendar ); | 214 | text = icalcomponent_as_ical_string( calendar ); |
235 | qApp->processEvents(); | 215 | qApp->processEvents(); |
236 | 216 | ||
237 | // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n"; | 217 | // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n"; |
238 | 218 | ||
239 | 219 | ||
240 | if ( text ) { | 220 | if ( text ) { |
241 | ret = QString ( text ); | 221 | ret = QString ( text ); |
242 | } | 222 | } |
243 | icalcomponent_free( calendar ); | 223 | icalcomponent_free( calendar ); |
244 | 224 | ||
245 | if (!text) { | 225 | if (!text) { |
246 | setException(new ErrorFormat(ErrorFormat::SaveError, | 226 | setException(new ErrorFormat(ErrorFormat::SaveError, |
247 | i18n("libical error"))); | 227 | i18n("libical error"))); |
248 | return QString::null; | 228 | return QString::null; |
249 | } | 229 | } |
250 | 230 | ||
251 | return ret; | 231 | return ret; |
252 | } | 232 | } |
253 | 233 | ||
254 | QString ICalFormat::toICalString( Incidence *incidence ) | 234 | QString ICalFormat::toICalString( Incidence *incidence ) |
255 | { | 235 | { |
256 | CalendarLocal cal( mTimeZoneId ); | 236 | CalendarLocal cal( mTimeZoneId ); |
257 | cal.addIncidence( incidence->clone() ); | 237 | cal.addIncidence( incidence->clone() ); |
258 | return toString( &cal ); | 238 | return toString( &cal ); |
259 | } | 239 | } |
260 | 240 | ||
261 | QString ICalFormat::toString( Incidence *incidence ) | 241 | QString ICalFormat::toString( Incidence *incidence ) |
262 | { | 242 | { |
263 | icalcomponent *component; | 243 | icalcomponent *component; |
264 | 244 | ||
265 | component = mImpl->writeIncidence( incidence ); | 245 | component = mImpl->writeIncidence( incidence ); |
266 | 246 | ||
267 | const char *text = icalcomponent_as_ical_string( component ); | 247 | const char *text = icalcomponent_as_ical_string( component ); |
268 | 248 | ||
269 | icalcomponent_free( component ); | 249 | icalcomponent_free( component ); |
270 | 250 | ||
271 | return QString::fromLocal8Bit( text ); | 251 | return QString::fromLocal8Bit( text ); |
272 | } | 252 | } |
273 | 253 | ||
274 | QString ICalFormat::toString( Recurrence *recurrence ) | 254 | QString ICalFormat::toString( Recurrence *recurrence ) |
275 | { | 255 | { |
276 | icalproperty *property; | 256 | icalproperty *property; |
277 | property = mImpl->writeRecurrenceRule( recurrence ); | 257 | property = mImpl->writeRecurrenceRule( recurrence ); |
278 | const char *text = icalproperty_as_ical_string( property ); | 258 | const char *text = icalproperty_as_ical_string( property ); |
279 | icalproperty_free( property ); | 259 | icalproperty_free( property ); |
280 | return QString::fromLocal8Bit( text ); | 260 | return QString::fromLocal8Bit( text ); |
281 | } | 261 | } |
282 | /* | 262 | /* |
283 | bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule ) | 263 | bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule ) |
284 | { | 264 | { |
285 | bool success = true; | 265 | bool success = true; |
286 | icalerror_clear_errno(); | 266 | icalerror_clear_errno(); |
287 | struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule ); | 267 | struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule ); |
288 | if ( icalerrno != ICAL_NO_ERROR ) { | 268 | if ( icalerrno != ICAL_NO_ERROR ) { |
289 | kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl; | 269 | kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl; |
290 | success = false; | 270 | success = false; |
291 | } | 271 | } |
292 | 272 | ||
293 | if ( success ) { | 273 | if ( success ) { |
294 | mImpl->readRecurrence( recur, recurrence ); | 274 | mImpl->readRecurrence( recur, recurrence ); |
295 | } | 275 | } |
296 | 276 | ||
297 | return success; | 277 | return success; |
298 | } | 278 | } |
299 | */ | 279 | */ |
300 | 280 | ||
301 | QString ICalFormat::createScheduleMessage(IncidenceBase *incidence, | 281 | QString ICalFormat::createScheduleMessage(IncidenceBase *incidence, |
302 | Scheduler::Method method) | 282 | Scheduler::Method method) |
303 | { | 283 | { |
304 | icalcomponent *message = mImpl->createScheduleComponent(incidence,method); | 284 | icalcomponent *message = mImpl->createScheduleComponent(incidence,method); |
305 | 285 | ||
306 | QString messageText = icalcomponent_as_ical_string(message); | 286 | QString messageText = icalcomponent_as_ical_string(message); |
307 | 287 | ||
308 | 288 | ||
309 | 289 | ||
310 | return messageText; | 290 | return messageText; |
311 | } | 291 | } |
312 | 292 | ||
313 | ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, | 293 | ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, |
314 | const QString &messageText ) | 294 | const QString &messageText ) |
315 | { | 295 | { |
316 | setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); | 296 | setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); |
317 | clearException(); | 297 | clearException(); |
318 | 298 | ||
319 | if (messageText.isEmpty()) return 0; | 299 | if (messageText.isEmpty()) return 0; |
320 | 300 | ||
321 | icalcomponent *message; | 301 | icalcomponent *message; |
322 | message = icalparser_parse_string(messageText.local8Bit()); | 302 | message = icalparser_parse_string(messageText.local8Bit()); |
323 | 303 | ||
324 | if (!message) return 0; | 304 | if (!message) return 0; |
325 | 305 | ||
326 | icalproperty *m = icalcomponent_get_first_property(message, | 306 | icalproperty *m = icalcomponent_get_first_property(message, |
327 | ICAL_METHOD_PROPERTY); | 307 | ICAL_METHOD_PROPERTY); |
328 | 308 | ||
329 | if (!m) return 0; | 309 | if (!m) return 0; |
330 | 310 | ||
331 | icalcomponent *c; | 311 | icalcomponent *c; |
332 | 312 | ||
333 | IncidenceBase *incidence = 0; | 313 | IncidenceBase *incidence = 0; |
334 | c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT); | 314 | c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT); |
335 | if (c) { | 315 | if (c) { |
336 | incidence = mImpl->readEvent(c); | 316 | incidence = mImpl->readEvent(c); |
337 | } | 317 | } |
338 | 318 | ||
339 | if (!incidence) { | 319 | if (!incidence) { |
340 | c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT); | 320 | c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT); |
341 | if (c) { | 321 | if (c) { |
342 | incidence = mImpl->readTodo(c); | 322 | incidence = mImpl->readTodo(c); |
343 | } | 323 | } |
344 | } | 324 | } |
345 | 325 | ||
346 | if (!incidence) { | 326 | if (!incidence) { |
347 | c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT); | 327 | c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT); |
348 | if (c) { | 328 | if (c) { |
349 | incidence = mImpl->readFreeBusy(c); | 329 | incidence = mImpl->readFreeBusy(c); |
350 | } | 330 | } |
351 | } | 331 | } |
352 | 332 | ||
353 | if (!incidence) { | 333 | if (!incidence) { |
354 | kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl; | 334 | kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl; |
355 | return 0; | 335 | return 0; |
356 | } | 336 | } |
357 | 337 | ||
358 | kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl; | 338 | kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl; |
359 | 339 | ||
360 | icalproperty_method icalmethod = icalproperty_get_method(m); | 340 | icalproperty_method icalmethod = icalproperty_get_method(m); |
361 | Scheduler::Method method; | 341 | Scheduler::Method method; |
362 | 342 | ||
363 | switch (icalmethod) { | 343 | switch (icalmethod) { |
364 | case ICAL_METHOD_PUBLISH: | 344 | case ICAL_METHOD_PUBLISH: |
365 | method = Scheduler::Publish; | 345 | method = Scheduler::Publish; |
366 | break; | 346 | break; |
367 | case ICAL_METHOD_REQUEST: | 347 | case ICAL_METHOD_REQUEST: |
368 | method = Scheduler::Request; | 348 | method = Scheduler::Request; |
369 | break; | 349 | break; |
370 | case ICAL_METHOD_REFRESH: | 350 | case ICAL_METHOD_REFRESH: |
371 | method = Scheduler::Refresh; | 351 | method = Scheduler::Refresh; |
372 | break; | 352 | break; |
373 | case ICAL_METHOD_CANCEL: | 353 | case ICAL_METHOD_CANCEL: |
374 | method = Scheduler::Cancel; | 354 | method = Scheduler::Cancel; |
375 | break; | 355 | break; |
376 | case ICAL_METHOD_ADD: | 356 | case ICAL_METHOD_ADD: |
377 | method = Scheduler::Add; | 357 | method = Scheduler::Add; |
378 | break; | 358 | break; |
379 | case ICAL_METHOD_REPLY: | 359 | case ICAL_METHOD_REPLY: |
380 | method = Scheduler::Reply; | 360 | method = Scheduler::Reply; |
381 | break; | 361 | break; |
382 | case ICAL_METHOD_COUNTER: | 362 | case ICAL_METHOD_COUNTER: |
383 | method = Scheduler::Counter; | 363 | method = Scheduler::Counter; |
384 | break; | 364 | break; |
385 | case ICAL_METHOD_DECLINECOUNTER: | 365 | case ICAL_METHOD_DECLINECOUNTER: |
386 | method = Scheduler::Declinecounter; | 366 | method = Scheduler::Declinecounter; |
387 | break; | 367 | break; |
388 | default: | 368 | default: |
389 | method = Scheduler::NoMethod; | 369 | method = Scheduler::NoMethod; |
390 | kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; | 370 | kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; |
391 | break; | 371 | break; |
392 | } | 372 | } |
393 | 373 | ||
394 | 374 | ||
395 | if (!icalrestriction_check(message)) { | 375 | if (!icalrestriction_check(message)) { |
396 | setException(new ErrorFormat(ErrorFormat::Restriction, | 376 | setException(new ErrorFormat(ErrorFormat::Restriction, |
397 | Scheduler::translatedMethodName(method) + ": " + | 377 | Scheduler::translatedMethodName(method) + ": " + |
398 | mImpl->extractErrorProperty(c))); | 378 | mImpl->extractErrorProperty(c))); |
399 | return 0; | 379 | return 0; |
400 | } | 380 | } |
401 | 381 | ||
402 | icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); | 382 | icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); |
403 | 383 | ||
404 | Incidence *existingIncidence = cal->event(incidence->uid()); | 384 | Incidence *existingIncidence = cal->event(incidence->uid()); |
405 | if (existingIncidence) { | 385 | if (existingIncidence) { |
406 | // TODO: check, if cast is required, or if it can be done by virtual funcs. | 386 | // TODO: check, if cast is required, or if it can be done by virtual funcs. |
407 | if (existingIncidence->type() == "Todo") { | 387 | if (existingIncidence->type() == "Todo") { |
408 | Todo *todo = static_cast<Todo *>(existingIncidence); | 388 | Todo *todo = static_cast<Todo *>(existingIncidence); |
409 | icalcomponent_add_component(calendarComponent, | 389 | icalcomponent_add_component(calendarComponent, |
410 | mImpl->writeTodo(todo)); | 390 | mImpl->writeTodo(todo)); |
411 | } | 391 | } |
412 | if (existingIncidence->type() == "Event") { | 392 | if (existingIncidence->type() == "Event") { |
413 | Event *event = static_cast<Event *>(existingIncidence); | 393 | Event *event = static_cast<Event *>(existingIncidence); |
414 | icalcomponent_add_component(calendarComponent, | 394 | icalcomponent_add_component(calendarComponent, |
415 | mImpl->writeEvent(event)); | 395 | mImpl->writeEvent(event)); |
416 | } | 396 | } |
417 | } else { | 397 | } else { |
418 | calendarComponent = 0; | 398 | calendarComponent = 0; |
419 | } | 399 | } |
420 | qDebug("icalclassify commented out "); | 400 | qDebug("icalclassify commented out "); |
421 | ScheduleMessage::Status status; | 401 | ScheduleMessage::Status status; |
422 | #if 0 | 402 | #if 0 |
423 | 403 | ||
424 | icalclass result = icalclassify(message,calendarComponent,(char *)""); | 404 | icalclass result = icalclassify(message,calendarComponent,(char *)""); |
425 | 405 | ||
426 | 406 | ||
427 | 407 | ||
428 | switch (result) { | 408 | switch (result) { |
429 | case ICAL_PUBLISH_NEW_CLASS: | 409 | case ICAL_PUBLISH_NEW_CLASS: |
430 | status = ScheduleMessage::PublishNew; | 410 | status = ScheduleMessage::PublishNew; |
431 | break; | 411 | break; |
432 | case ICAL_OBSOLETE_CLASS: | 412 | case ICAL_OBSOLETE_CLASS: |
433 | status = ScheduleMessage::Obsolete; | 413 | status = ScheduleMessage::Obsolete; |
434 | break; | 414 | break; |
435 | case ICAL_REQUEST_NEW_CLASS: | 415 | case ICAL_REQUEST_NEW_CLASS: |
436 | status = ScheduleMessage::RequestNew; | 416 | status = ScheduleMessage::RequestNew; |
437 | break; | 417 | break; |
438 | case ICAL_REQUEST_UPDATE_CLASS: | 418 | case ICAL_REQUEST_UPDATE_CLASS: |
439 | status = ScheduleMessage::RequestUpdate; | 419 | status = ScheduleMessage::RequestUpdate; |
440 | break; | 420 | break; |
441 | case ICAL_UNKNOWN_CLASS: | 421 | case ICAL_UNKNOWN_CLASS: |
442 | default: | 422 | default: |
443 | status = ScheduleMessage::Unknown; | 423 | status = ScheduleMessage::Unknown; |
444 | break; | 424 | break; |
445 | } | 425 | } |
446 | #endif | 426 | #endif |
447 | status = ScheduleMessage::RequestUpdate; | 427 | status = ScheduleMessage::RequestUpdate; |
448 | return new ScheduleMessage(incidence,method,status); | 428 | return new ScheduleMessage(incidence,method,status); |
449 | } | 429 | } |
450 | 430 | ||
451 | void ICalFormat::setTimeZone( const QString &id, bool utc ) | 431 | void ICalFormat::setTimeZone( const QString &id, bool utc ) |
452 | { | 432 | { |
453 | 433 | ||
454 | 434 | ||
455 | mTimeZoneId = id; | 435 | mTimeZoneId = id; |
456 | mUtc = utc; | 436 | mUtc = utc; |
457 | 437 | ||
458 | tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 438 | tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
459 | 439 | ||
460 | //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin); | 440 | //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin); |
461 | } | 441 | } |
462 | 442 | ||
463 | QString ICalFormat::timeZoneId() const | 443 | QString ICalFormat::timeZoneId() const |
464 | { | 444 | { |
465 | return mTimeZoneId; | 445 | return mTimeZoneId; |
466 | } | 446 | } |
467 | 447 | ||
468 | bool ICalFormat::utc() const | 448 | bool ICalFormat::utc() const |
469 | { | 449 | { |
470 | return mUtc; | 450 | return mUtc; |
471 | } | 451 | } |
472 | int ICalFormat::timeOffset() | 452 | int ICalFormat::timeOffset() |
473 | { | 453 | { |
474 | return tzOffsetMin; | 454 | return tzOffsetMin; |
475 | } | 455 | } |
476 | const char *ICalFormat::tzString() | 456 | const char *ICalFormat::tzString() |
477 | { | 457 | { |
478 | const char* ret = (const char* ) mTzString; | 458 | const char* ret = (const char* ) mTzString; |
479 | return ret; | 459 | return ret; |
480 | } | 460 | } |
diff --git a/libkcal/icalformat.h b/libkcal/icalformat.h index 236efbf..485ab6e 100644 --- a/libkcal/icalformat.h +++ b/libkcal/icalformat.h | |||
@@ -1,116 +1,115 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
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 | #ifndef ICALFORMAT_H | 20 | #ifndef ICALFORMAT_H |
21 | #define ICALFORMAT_H | 21 | #define ICALFORMAT_H |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | 24 | ||
25 | #include "scheduler.h" | 25 | #include "scheduler.h" |
26 | 26 | ||
27 | #include "calformat.h" | 27 | #include "calformat.h" |
28 | 28 | ||
29 | namespace KCal { | 29 | namespace KCal { |
30 | 30 | ||
31 | class ICalFormatImpl; | 31 | class ICalFormatImpl; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | This class implements the iCalendar format. It provides methods for | 34 | This class implements the iCalendar format. It provides methods for |
35 | loading/saving/converting iCalendar format data into the internal KOrganizer | 35 | loading/saving/converting iCalendar format data into the internal KOrganizer |
36 | representation as Calendar and Events. | 36 | representation as Calendar and Events. |
37 | 37 | ||
38 | @short iCalendar format implementation | 38 | @short iCalendar format implementation |
39 | */ | 39 | */ |
40 | class ICalFormat : public CalFormat { | 40 | class ICalFormat : public CalFormat { |
41 | public: | 41 | public: |
42 | /** Create new iCalendar format. */ | 42 | /** Create new iCalendar format. */ |
43 | ICalFormat( bool quick = false ); | 43 | ICalFormat( ); |
44 | virtual ~ICalFormat(); | 44 | virtual ~ICalFormat(); |
45 | 45 | ||
46 | /** | 46 | /** |
47 | Loads a calendar on disk in iCalendar format into calendar. | 47 | Loads a calendar on disk in iCalendar format into calendar. |
48 | Returns true if successful, else returns false. Provides more error | 48 | Returns true if successful, else returns false. Provides more error |
49 | information by exception(). | 49 | information by exception(). |
50 | @param calendar Calendar object to be filled. | 50 | @param calendar Calendar object to be filled. |
51 | @param fileName The name of the calendar file on disk. | 51 | @param fileName The name of the calendar file on disk. |
52 | */ | 52 | */ |
53 | bool load( Calendar *, const QString &fileName ); | 53 | bool load( Calendar *, const QString &fileName ); |
54 | /** | 54 | /** |
55 | Writes out the calendar to disk in iCalendar format. Returns true if | 55 | Writes out the calendar to disk in iCalendar format. Returns true if |
56 | successful and false on error. | 56 | successful and false on error. |
57 | 57 | ||
58 | @param calendar The Calendar object to be written. | 58 | @param calendar The Calendar object to be written. |
59 | @param fileName The name of the calendar file on disk. | 59 | @param fileName The name of the calendar file on disk. |
60 | */ | 60 | */ |
61 | bool save( Calendar *, const QString &fileName ); | 61 | bool save( Calendar *, const QString &fileName ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | Parse string and populate calendar with that information. | 64 | Parse string and populate calendar with that information. |
65 | */ | 65 | */ |
66 | bool fromString( Calendar *, const QString & ); | 66 | bool fromString( Calendar *, const QString & ); |
67 | /** | 67 | /** |
68 | Parse string and return first ical component. | 68 | Parse string and return first ical component. |
69 | */ | 69 | */ |
70 | Incidence *fromString( const QString & ); | 70 | Incidence *fromString( const QString & ); |
71 | /** | 71 | /** |
72 | Return calendar information as string. | 72 | Return calendar information as string. |
73 | */ | 73 | */ |
74 | QString toString( Calendar * ); | 74 | QString toString( Calendar * ); |
75 | /** | 75 | /** |
76 | Return incidence as full iCalendar formatted text. | 76 | Return incidence as full iCalendar formatted text. |
77 | */ | 77 | */ |
78 | QString toICalString( Incidence * ); | 78 | QString toICalString( Incidence * ); |
79 | /** | 79 | /** |
80 | Return incidence as iCalendar formatted text. | 80 | Return incidence as iCalendar formatted text. |
81 | */ | 81 | */ |
82 | QString toString( Incidence * ); | 82 | QString toString( Incidence * ); |
83 | /** | 83 | /** |
84 | Return recurrence as iCalendar formatted text. | 84 | Return recurrence as iCalendar formatted text. |
85 | */ | 85 | */ |
86 | QString toString( Recurrence * ); | 86 | QString toString( Recurrence * ); |
87 | /** | 87 | /** |
88 | Parse string and fill recurrence object with | 88 | Parse string and fill recurrence object with |
89 | that information | 89 | that information |
90 | */ | 90 | */ |
91 | //bool fromString ( Recurrence *, const QString& ); | 91 | //bool fromString ( Recurrence *, const QString& ); |
92 | 92 | ||
93 | /** Create a scheduling message for event \a e using method \m */ | 93 | /** Create a scheduling message for event \a e using method \m */ |
94 | QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m); | 94 | QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m); |
95 | /** Parse scheduling message provided as string \s */ | 95 | /** Parse scheduling message provided as string \s */ |
96 | ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s); | 96 | ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s); |
97 | 97 | ||
98 | /** Set id of used time zone and whether this time zone is UTC or not. */ | 98 | /** Set id of used time zone and whether this time zone is UTC or not. */ |
99 | void setTimeZone( const QString &id, bool utc ); | 99 | void setTimeZone( const QString &id, bool utc ); |
100 | QString timeZoneId() const; | 100 | QString timeZoneId() const; |
101 | int timeOffset(); | 101 | int timeOffset(); |
102 | const char * tzString(); | 102 | const char * tzString(); |
103 | bool utc() const; | 103 | bool utc() const; |
104 | 104 | ||
105 | private: | 105 | private: |
106 | ICalFormatImpl *mImpl; | 106 | ICalFormatImpl *mImpl; |
107 | bool mQuicksave; | ||
108 | QString mTimeZoneId; | 107 | QString mTimeZoneId; |
109 | QCString mTzString; | 108 | QCString mTzString; |
110 | int tzOffsetMin; | 109 | int tzOffsetMin; |
111 | bool mUtc; | 110 | bool mUtc; |
112 | }; | 111 | }; |
113 | 112 | ||
114 | } | 113 | } |
115 | 114 | ||
116 | #endif | 115 | #endif |