1/*
2 This file is part of the kcalcore library.
3
4 Copyright (c) 2002,2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21/**
22 @file
23 This file is part of the API for handling calendar data and
24 defines the FileStorage class.
25
26 @author Cornelius Schumacher \<schumacher@kde.org\>
27*/
28
29#ifndef KCALCORE_FILESTORAGE_H
30#define KCALCORE_FILESTORAGE_H
31
32#include "kcalcore_export.h"
33#include "calstorage.h"
34
35namespace KCalCore {
36
37class CalFormat;
38class Calendar;
39
40/**
41 @brief
42 This class provides a calendar storage as a local file.
43*/
44class KCALCORE_EXPORT FileStorage : public CalStorage
45{
46public:
47
48 /**
49 A shared pointer to a FileStorage.
50 */
51 typedef QSharedPointer<FileStorage> Ptr;
52
53 /**
54 Constructs a new FileStorage object for Calendar @p calendar with format
55 @p format, and storage to file @p fileName.
56
57 @param calendar is a pointer to a valid Calendar object.
58 @param fileName is the name of the disk file containing the calendar data.
59 @param format is a pointer to a valid CalFormat object that specifies
60 the calendar format to be used. FileStorage takes ownership; i.e., the
61 memory for @p format is deleted by this destructor. If no format is
62 specified, then iCalendar format is assumed.
63 */
64 explicit FileStorage(const Calendar::Ptr &calendar,
65 const QString &fileName = QString(),
66 KCalCore::CalFormat *format = 0);
67
68 /**
69 Destructor.
70 */
71 virtual ~FileStorage();
72
73 /**
74 Sets the name of the file that contains the calendar data.
75
76 @param fileName is the name of the disk file containing the calendar data.
77 @see fileName().
78 */
79 void setFileName(const QString &fileName);
80
81 /**
82 Returns the calendar file name.
83 @return A QString with the name of the calendar file for this storge.
84 @see setFileName().
85 */
86 QString fileName() const;
87
88 /**
89 Sets the CalFormat object to use for this storage.
90
91 @param format is a pointer to a valid CalFormat object that specifies
92 the calendar format to be used. FileStorage takes ownership.
93 @see saveFormat().
94 */
95 void setSaveFormat(KCalCore::CalFormat *format);
96
97 /**
98 Returns the CalFormat object used by this storage.
99 @return A pointer to the CalFormat object used by this storage.
100 @see setSaveFormat().
101 */
102 CalFormat *saveFormat() const;
103
104 /**
105 @copydoc CalStorage::open()
106 */
107 bool open();
108
109 /**
110 @copydoc CalStorage::load()
111 */
112 bool load();
113
114 /**
115 @copydoc CalStorage::save()
116 */
117 bool save();
118
119 /**
120 @copydoc CalStorage::close()
121 */
122 bool close();
123
124private:
125 //@cond PRIVATE
126 Q_DISABLE_COPY(FileStorage)
127 class Private;
128 Private *const d;
129 //@endcond
130};
131
132}
133
134#endif
135