author | zautrix <zautrix> | 2005-04-03 23:09:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-03 23:09:08 (UTC) |
commit | 06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5 (patch) (unidiff) | |
tree | a9f01377dc21931e5d267edc3b196232f244d1fb | |
parent | 30359da3c126e67f6c75400323fcca4c159c3d93 (diff) | |
download | kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.zip kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.tar.gz kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.tar.bz2 |
sync fix
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 18 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.h | 1 |
2 files changed, 13 insertions, 6 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 0e6c2a3..af76558 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -1,263 +1,269 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
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 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #ifndef _WIN32_ | 30 | #ifndef _WIN32_ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
46 | 46 | ||
47 | #include "formatfactory.h" | 47 | #include "formatfactory.h" |
48 | 48 | ||
49 | #include "resource.h" | 49 | #include "resource.h" |
50 | #include "resourcefileconfig.h" | 50 | #include "resourcefileconfig.h" |
51 | #include "stdaddressbook.h" | 51 | #include "stdaddressbook.h" |
52 | #define NO_DIRWATCH | 52 | #define NO_DIRWATCH |
53 | #include "resourcefile.h" | 53 | #include "resourcefile.h" |
54 | 54 | ||
55 | //#define ALLOW_LOCKING | 55 | //#define ALLOW_LOCKING |
56 | 56 | ||
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | extern "C" | 60 | extern "C" |
61 | #ifdef _WIN32_ | 61 | #ifdef _WIN32_ |
62 | __declspec(dllexport) | 62 | __declspec(dllexport) |
63 | #else | 63 | #else |
64 | { | 64 | { |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | //US void *init_kabc_file() | 67 | //US void *init_kabc_file() |
68 | void *init_microkabc_file() | 68 | void *init_microkabc_file() |
69 | { | 69 | { |
70 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); | 70 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); |
71 | } | 71 | } |
72 | #ifndef _WIN32_ | 72 | #ifndef _WIN32_ |
73 | } | 73 | } |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | ResourceFile::ResourceFile( const KConfig *config ) | 76 | ResourceFile::ResourceFile( const KConfig *config ) |
77 | : Resource( config ) , mFormat( 0 ) | 77 | : Resource( config ) , mFormat( 0 ) |
78 | { | 78 | { |
79 | QString fileName, formatName, default_fileName; | 79 | QString fileName, formatName, default_fileName; |
80 | 80 | ||
81 | default_fileName = StdAddressBook::fileName(); | 81 | default_fileName = StdAddressBook::fileName(); |
82 | 82 | ||
83 | KConfig *cfg = (KConfig *)config; | 83 | KConfig *cfg = (KConfig *)config; |
84 | if ( cfg ) { | 84 | if ( cfg ) { |
85 | fileName = cfg->readEntry( "FileName", default_fileName ); | 85 | fileName = cfg->readEntry( "FileName", default_fileName ); |
86 | formatName = cfg->readEntry( "FileFormat", "vcard" ); | 86 | formatName = cfg->readEntry( "FileFormat", "vcard" ); |
87 | mFamily = cfg->readEntry( "ResourceName", "std" ); | ||
87 | } else { | 88 | } else { |
88 | fileName = default_fileName; | 89 | fileName = default_fileName; |
89 | formatName = "vcard"; | 90 | formatName = "vcard"; |
90 | } | 91 | } |
91 | 92 | ||
92 | init( fileName, formatName ); | 93 | init( fileName, formatName ); |
93 | } | 94 | } |
94 | 95 | ||
95 | ResourceFile::ResourceFile( const QString &fileName , | 96 | ResourceFile::ResourceFile( const QString &fileName , |
96 | const QString &formatName ) | 97 | const QString &formatName ) |
97 | : Resource( 0 ) | 98 | : Resource( 0 ) |
98 | { | 99 | { |
99 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 100 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
100 | 101 | ||
101 | 102 | ||
102 | 103 | ||
103 | init( fileName, formatName ); | 104 | init( fileName, formatName ); |
104 | } | 105 | } |
105 | 106 | ||
106 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 107 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
107 | { | 108 | { |
108 | mFormatName = formatName; | 109 | mFormatName = formatName; |
109 | 110 | ||
110 | FormatFactory *factory = FormatFactory::self(); | 111 | FormatFactory *factory = FormatFactory::self(); |
111 | mFormat = factory->format( mFormatName ); | 112 | mFormat = factory->format( mFormatName ); |
112 | 113 | ||
113 | if ( !mFormat ) { | 114 | if ( !mFormat ) { |
114 | mFormatName = "vcard"; | 115 | mFormatName = "vcard"; |
115 | mFormat = factory->format( mFormatName ); | 116 | mFormat = factory->format( mFormatName ); |
116 | } | 117 | } |
117 | 118 | ||
118 | #ifndef NO_DIRWATCH | 119 | #ifndef NO_DIRWATCH |
119 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 120 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
120 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 121 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
121 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 122 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
122 | #endif | 123 | #endif |
123 | 124 | ||
124 | 125 | QString localKdeDir; | |
125 | QString localKdeDir; | ||
126 | localKdeDir = readEnvPath("LOCALMICROKDEHOME"); | 126 | localKdeDir = readEnvPath("LOCALMICROKDEHOME"); |
127 | if ( ! localKdeDir.isEmpty() ) { | 127 | if ( ! localKdeDir.isEmpty() ) { |
128 | qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() ); | 128 | qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() ); |
129 | QFileInfo fi ( fileName ); | 129 | QFileInfo fi ( fileName ); |
130 | QString localname = localKdeDir + "/apps/kabc/" + fi.fileName (); | 130 | QString localname = localKdeDir + "/apps/kabc/" + fi.fileName (); |
131 | QFileInfo fi2 ( localname ); | 131 | QFileInfo fi2 ( localname ); |
132 | if ( ! fi2.exists() ) { | 132 | if ( ! fi2.exists() || mFamily == "sync_res" ) { |
133 | KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") ); | 133 | if ( fi.exists() && mFamily == "sync_res") { |
134 | setFileName( localname ); | 134 | qDebug("LOCAL mode SYNC mode using absolute file path "); |
135 | return; | 135 | setFileName( fileName ); |
136 | return; | ||
137 | } else { | ||
138 | KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") ); | ||
139 | setFileName( localname ); | ||
140 | return; | ||
141 | } | ||
136 | 142 | ||
137 | } else { | 143 | } else { |
138 | qDebug("Local resource file found. Changing filename to: %s",localname.latin1() ); | 144 | qDebug("Local resource file found. Changing filename to: %s",localname.latin1() ); |
139 | setFileName( localname ); | 145 | setFileName( localname ); |
140 | return; | 146 | return; |
141 | } | 147 | } |
142 | 148 | ||
143 | } | 149 | } |
144 | setFileName( fileName ); | 150 | setFileName( fileName ); |
145 | } | 151 | } |
146 | 152 | ||
147 | ResourceFile::~ResourceFile() | 153 | ResourceFile::~ResourceFile() |
148 | { | 154 | { |
149 | delete mFormat; | 155 | delete mFormat; |
150 | mFormat = 0; | 156 | mFormat = 0; |
151 | } | 157 | } |
152 | 158 | ||
153 | void ResourceFile::writeConfig( KConfig *config ) | 159 | void ResourceFile::writeConfig( KConfig *config ) |
154 | { | 160 | { |
155 | 161 | ||
156 | config->setGroup( "Resource_" + identifier() ); | 162 | config->setGroup( "Resource_" + identifier() ); |
157 | Resource::writeConfig( config ); | 163 | Resource::writeConfig( config ); |
158 | 164 | ||
159 | config->writeEntry( "FileName", fileName() ); | 165 | config->writeEntry( "FileName", fileName() ); |
160 | config->writeEntry( "FileFormat", mFormatName ); | 166 | config->writeEntry( "FileFormat", mFormatName ); |
161 | 167 | ||
162 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 168 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
163 | 169 | ||
164 | } | 170 | } |
165 | 171 | ||
166 | Ticket *ResourceFile::requestSaveTicket() | 172 | Ticket *ResourceFile::requestSaveTicket() |
167 | { | 173 | { |
168 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; | 174 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; |
169 | 175 | ||
170 | if ( !addressBook() ) return 0; | 176 | if ( !addressBook() ) return 0; |
171 | 177 | ||
172 | #ifdef ALLOW_LOCKING | 178 | #ifdef ALLOW_LOCKING |
173 | if ( !lock( mFileName ) ) { | 179 | if ( !lock( mFileName ) ) { |
174 | qDebug("unablt to lock file "); | 180 | qDebug("unablt to lock file "); |
175 | return 0; | 181 | return 0; |
176 | } | 182 | } |
177 | #endif | 183 | #endif |
178 | return createTicket( this ); | 184 | return createTicket( this ); |
179 | } | 185 | } |
180 | 186 | ||
181 | 187 | ||
182 | bool ResourceFile::doOpen() | 188 | bool ResourceFile::doOpen() |
183 | { | 189 | { |
184 | QFile file( fileName() ); | 190 | QFile file( fileName() ); |
185 | qDebug("ResourceFile::openfile %s ", fileName().latin1()); | 191 | qDebug("ResourceFile::openfile %s ", fileName().latin1()); |
186 | 192 | ||
187 | if ( !file.exists() ) { | 193 | if ( !file.exists() ) { |
188 | // try to create the file | 194 | // try to create the file |
189 | bool ok = file.open( IO_WriteOnly ); | 195 | bool ok = file.open( IO_WriteOnly ); |
190 | if ( ok ) | 196 | if ( ok ) |
191 | file.close(); | 197 | file.close(); |
192 | 198 | ||
193 | return ok; | 199 | return ok; |
194 | } else { | 200 | } else { |
195 | if ( !file.open( IO_ReadWrite ) ) | 201 | if ( !file.open( IO_ReadWrite ) ) |
196 | return false; | 202 | return false; |
197 | 203 | ||
198 | if ( file.size() == 0 ) { | 204 | if ( file.size() == 0 ) { |
199 | file.close(); | 205 | file.close(); |
200 | return true; | 206 | return true; |
201 | } | 207 | } |
202 | 208 | ||
203 | bool ok = mFormat->checkFormat( &file ); | 209 | bool ok = mFormat->checkFormat( &file ); |
204 | file.close(); | 210 | file.close(); |
205 | 211 | ||
206 | return ok; | 212 | return ok; |
207 | } | 213 | } |
208 | } | 214 | } |
209 | 215 | ||
210 | void ResourceFile::doClose() | 216 | void ResourceFile::doClose() |
211 | { | 217 | { |
212 | } | 218 | } |
213 | 219 | ||
214 | bool ResourceFile::load() | 220 | bool ResourceFile::load() |
215 | { | 221 | { |
216 | 222 | ||
217 | QFile file( fileName() ); | 223 | QFile file( fileName() ); |
218 | if ( !file.open( IO_ReadOnly ) ) { | 224 | if ( !file.open( IO_ReadOnly ) ) { |
219 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) ); | 225 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) ); |
220 | return false; | 226 | return false; |
221 | } | 227 | } |
222 | 228 | ||
223 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 229 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
224 | 230 | ||
225 | return mFormat->loadAll( addressBook(), this, &file ); | 231 | return mFormat->loadAll( addressBook(), this, &file ); |
226 | } | 232 | } |
227 | 233 | ||
228 | bool ResourceFile::save( Ticket *ticket ) | 234 | bool ResourceFile::save( Ticket *ticket ) |
229 | { | 235 | { |
230 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 236 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
231 | 237 | ||
232 | 238 | ||
233 | // create backup file | 239 | // create backup file |
234 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | 240 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); |
235 | 241 | ||
236 | /*US we use a simpler method to create a backupfile | 242 | /*US we use a simpler method to create a backupfile |
237 | 243 | ||
238 | (void) KSaveFile::backupFile( mFileName, QString::null | 244 | (void) KSaveFile::backupFile( mFileName, QString::null |
239 | ,extension ); | 245 | ,extension ); |
240 | 246 | ||
241 | KSaveFile saveFile( mFileName ); | 247 | KSaveFile saveFile( mFileName ); |
242 | bool ok = false; | 248 | bool ok = false; |
243 | if ( saveFile.status() == 0 && saveFile.file() ) | 249 | if ( saveFile.status() == 0 && saveFile.file() ) |
244 | { | 250 | { |
245 | mFormat->saveAll( addressBook(), this, saveFile.file() ); | 251 | mFormat->saveAll( addressBook(), this, saveFile.file() ); |
246 | ok = saveFile.close(); | 252 | ok = saveFile.close(); |
247 | } | 253 | } |
248 | */ | 254 | */ |
249 | 255 | ||
250 | //US ToDo: write backupfile | 256 | //US ToDo: write backupfile |
251 | #ifndef NO_DIRWATCH | 257 | #ifndef NO_DIRWATCH |
252 | mDirWatch.stopScan(); | 258 | mDirWatch.stopScan(); |
253 | #endif | 259 | #endif |
254 | QFile info; | 260 | QFile info; |
255 | info.setName( fileName() ); | 261 | info.setName( fileName() ); |
256 | bool ok = info.open( IO_WriteOnly ); | 262 | bool ok = info.open( IO_WriteOnly ); |
257 | if ( ok ) { | 263 | if ( ok ) { |
258 | mFormat->saveAll( addressBook(), this, &info ); | 264 | mFormat->saveAll( addressBook(), this, &info ); |
259 | 265 | ||
260 | info.close(); | 266 | info.close(); |
261 | ok = true; | 267 | ok = true; |
262 | } | 268 | } |
263 | else { | 269 | else { |
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h index dd38a9d..3e9edfc 100644 --- a/kabc/plugins/file/resourcefile.h +++ b/kabc/plugins/file/resourcefile.h | |||
@@ -22,142 +22,143 @@ | |||
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #ifndef KABC_RESOURCEFILE_H | 29 | #ifndef KABC_RESOURCEFILE_H |
30 | #define KABC_RESOURCEFILE_H | 30 | #define KABC_RESOURCEFILE_H |
31 | 31 | ||
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdirwatch.h> | 33 | #include <kdirwatch.h> |
34 | 34 | ||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | 36 | ||
37 | #include <resource.h> | 37 | #include <resource.h> |
38 | 38 | ||
39 | class QTimer; | 39 | class QTimer; |
40 | class FormatPlugin; | 40 | class FormatPlugin; |
41 | 41 | ||
42 | namespace KABC { | 42 | namespace KABC { |
43 | 43 | ||
44 | //US class FormatPlugin; | 44 | //US class FormatPlugin; |
45 | class ResourceConfigWidget; | 45 | class ResourceConfigWidget; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | @internal | 48 | @internal |
49 | */ | 49 | */ |
50 | class ResourceFile : public Resource | 50 | class ResourceFile : public Resource |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | 55 | ||
56 | /** | 56 | /** |
57 | Constructor. | 57 | Constructor. |
58 | 58 | ||
59 | @param cfg The config object where custom resource settings are stored. | 59 | @param cfg The config object where custom resource settings are stored. |
60 | */ | 60 | */ |
61 | ResourceFile( const KConfig *cfg ); | 61 | ResourceFile( const KConfig *cfg ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | Construct file resource on file @arg fileName using format @arg formatName. | 64 | Construct file resource on file @arg fileName using format @arg formatName. |
65 | */ | 65 | */ |
66 | ResourceFile( const QString &fileName , const QString &formatName = "vcard" ); | 66 | ResourceFile( const QString &fileName , const QString &formatName = "vcard" ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Destructor. | 69 | * Destructor. |
70 | */ | 70 | */ |
71 | ~ResourceFile(); | 71 | ~ResourceFile(); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Writes the config back. | 74 | Writes the config back. |
75 | */ | 75 | */ |
76 | virtual void writeConfig( KConfig *cfg ); | 76 | virtual void writeConfig( KConfig *cfg ); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Tries to open the file and checks for the proper format. | 79 | * Tries to open the file and checks for the proper format. |
80 | * This method should be called before @ref load(). | 80 | * This method should be called before @ref load(). |
81 | */ | 81 | */ |
82 | virtual bool doOpen(); | 82 | virtual bool doOpen(); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Closes the file again. | 85 | * Closes the file again. |
86 | */ | 86 | */ |
87 | virtual void doClose(); | 87 | virtual void doClose(); |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Requests a save ticket, that is used by @ref save() | 90 | * Requests a save ticket, that is used by @ref save() |
91 | */ | 91 | */ |
92 | virtual Ticket *requestSaveTicket(); | 92 | virtual Ticket *requestSaveTicket(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Loads all addressees from file to the address book. | 95 | * Loads all addressees from file to the address book. |
96 | * Returns true if all addressees could be loaded otherwise false. | 96 | * Returns true if all addressees could be loaded otherwise false. |
97 | */ | 97 | */ |
98 | virtual bool load(); | 98 | virtual bool load(); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Saves all addresses from address book to file. | 101 | * Saves all addresses from address book to file. |
102 | * Returns true if all addressees could be saved otherwise false. | 102 | * Returns true if all addressees could be saved otherwise false. |
103 | * | 103 | * |
104 | * @param ticket The ticket returned by @ref requestSaveTicket() | 104 | * @param ticket The ticket returned by @ref requestSaveTicket() |
105 | */ | 105 | */ |
106 | virtual bool save( Ticket *ticket ); | 106 | virtual bool save( Ticket *ticket ); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Set name of file to be used for saving. | 109 | * Set name of file to be used for saving. |
110 | */ | 110 | */ |
111 | void setFileName( const QString & ); | 111 | void setFileName( const QString & ); |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * Return name of file used for loading and saving the address book. | 114 | * Return name of file used for loading and saving the address book. |
115 | */ | 115 | */ |
116 | QString fileName() const; | 116 | QString fileName() const; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | Sets a new format by name. | 119 | Sets a new format by name. |
120 | */ | 120 | */ |
121 | void setFormat( const QString &name ); | 121 | void setFormat( const QString &name ); |
122 | 122 | ||
123 | /** | 123 | /** |
124 | Returns the format name. | 124 | Returns the format name. |
125 | */ | 125 | */ |
126 | QString format() const; | 126 | QString format() const; |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Remove a addressee from its source. | 129 | * Remove a addressee from its source. |
130 | * This method is mainly called by KABC::AddressBook. | 130 | * This method is mainly called by KABC::AddressBook. |
131 | */ | 131 | */ |
132 | virtual void removeAddressee( const Addressee& addr ); | 132 | virtual void removeAddressee( const Addressee& addr ); |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * This method is called by an error handler if the application | 135 | * This method is called by an error handler if the application |
136 | * crashed | 136 | * crashed |
137 | */ | 137 | */ |
138 | virtual void cleanUp(); | 138 | virtual void cleanUp(); |
139 | 139 | ||
140 | protected slots: | 140 | protected slots: |
141 | void fileChanged(); | 141 | void fileChanged(); |
142 | 142 | ||
143 | protected: | 143 | protected: |
144 | void init( const QString &fileName, const QString &format ); | 144 | void init( const QString &fileName, const QString &format ); |
145 | 145 | ||
146 | bool lock( const QString &fileName ); | 146 | bool lock( const QString &fileName ); |
147 | void unlock( const QString &fileName ); | 147 | void unlock( const QString &fileName ); |
148 | 148 | ||
149 | private: | 149 | private: |
150 | QString mFamily; | ||
150 | QString mFileName2; | 151 | QString mFileName2; |
151 | QString mFormatName; | 152 | QString mFormatName; |
152 | 153 | ||
153 | FormatPlugin *mFormat; | 154 | FormatPlugin *mFormat; |
154 | 155 | ||
155 | QString mLockUniqueName; | 156 | QString mLockUniqueName; |
156 | #ifndef NO_DIRWATCH | 157 | #ifndef NO_DIRWATCH |
157 | KDirWatch mDirWatch; | 158 | KDirWatch mDirWatch; |
158 | #endif | 159 | #endif |
159 | }; | 160 | }; |
160 | 161 | ||
161 | } | 162 | } |
162 | 163 | ||
163 | #endif | 164 | #endif |