summaryrefslogtreecommitdiffabout
path: root/libkcal/filestorage.cpp
Unidiff
Diffstat (limited to 'libkcal/filestorage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/filestorage.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libkcal/filestorage.cpp b/libkcal/filestorage.cpp
index a139124..3d1309f 100644
--- a/libkcal/filestorage.cpp
+++ b/libkcal/filestorage.cpp
@@ -1,121 +1,121 @@
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 <q3ptrlist.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
36using namespace KCal; 36using namespace KCal;
37 37
38FileStorage::FileStorage( Calendar *cal, const QString &fileName, 38FileStorage::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
46FileStorage::~FileStorage() 46FileStorage::~FileStorage()
47{ 47{
48 delete mSaveFormat; 48 delete mSaveFormat;
49} 49}
50 50
51void FileStorage::setFileName( const QString &fileName ) 51void FileStorage::setFileName( const QString &fileName )
52{ 52{
53 mFileName = fileName; 53 mFileName = fileName;
54} 54}
55 55
56QString FileStorage::fileName()const 56QString FileStorage::fileName()const
57{ 57{
58 return mFileName; 58 return mFileName;
59} 59}
60 60
61 61
62void FileStorage::setSaveFormat( CalFormat *format ) 62void FileStorage::setSaveFormat( CalFormat *format )
63{ 63{
64 delete mSaveFormat; 64 delete mSaveFormat;
65 mSaveFormat = format; 65 mSaveFormat = format;
66} 66}
67 67
68CalFormat *FileStorage::saveFormat()const 68CalFormat *FileStorage::saveFormat()const
69{ 69{
70 return mSaveFormat; 70 return mSaveFormat;
71} 71}
72 72
73 73
74bool FileStorage::open() 74bool FileStorage::open()
75{ 75{
76 return true; 76 return true;
77} 77}
78 78
79bool FileStorage::load( ) 79bool 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; 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
119bool FileStorage::save() 119bool FileStorage::save()
120{ 120{
121 if ( mFileName.isEmpty() ) return false; 121 if ( mFileName.isEmpty() ) return false;