summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index af76558..2bd9e71 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -156,97 +156,97 @@ ResourceFile::~ResourceFile()
156 mFormat = 0; 156 mFormat = 0;
157} 157}
158 158
159void ResourceFile::writeConfig( KConfig *config ) 159void ResourceFile::writeConfig( KConfig *config )
160{ 160{
161 161
162 config->setGroup( "Resource_" + identifier() ); 162 config->setGroup( "Resource_" + identifier() );
163 Resource::writeConfig( config ); 163 Resource::writeConfig( config );
164 164
165 config->writeEntry( "FileName", fileName() ); 165 config->writeEntry( "FileName", fileName() );
166 config->writeEntry( "FileFormat", mFormatName ); 166 config->writeEntry( "FileFormat", mFormatName );
167 167
168// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 168// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
169 169
170} 170}
171 171
172Ticket *ResourceFile::requestSaveTicket() 172Ticket *ResourceFile::requestSaveTicket()
173{ 173{
174 kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; 174 kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl;
175 175
176 if ( !addressBook() ) return 0; 176 if ( !addressBook() ) return 0;
177 177
178#ifdef ALLOW_LOCKING 178#ifdef ALLOW_LOCKING
179 if ( !lock( mFileName ) ) { 179 if ( !lock( mFileName ) ) {
180 qDebug("unablt to lock file "); 180 qDebug("unablt to lock file ");
181 return 0; 181 return 0;
182 } 182 }
183#endif 183#endif
184 return createTicket( this ); 184 return createTicket( this );
185} 185}
186 186
187 187
188bool ResourceFile::doOpen() 188bool ResourceFile::doOpen()
189{ 189{
190 QFile file( fileName() ); 190 QFile file( fileName() );
191 qDebug("ResourceFile::openfile %s ", fileName().latin1()); 191 qDebug("ResourceFile::openfile %s ", fileName().latin1());
192 192
193 if ( !file.exists() ) { 193 if ( !file.exists() ) {
194 // try to create the file 194 // try to create the file
195 bool ok = file.open( IO_WriteOnly ); 195 bool ok = file.open( IO_WriteOnly );
196 if ( ok ) 196 if ( ok )
197 file.close(); 197 file.close();
198 198
199 return ok; 199 return ok;
200 } else { 200 } else {
201 if ( !file.open( IO_ReadWrite ) ) 201 if ( !file.open( IO_ReadWrite ) )
202 return false; 202 return false;
203 203
204 if ( file.size() == 0 ) { 204 if ( file.size() < 10 ) {
205 file.close(); 205 file.close();
206 return true; 206 return true;
207 } 207 }
208 208
209 bool ok = mFormat->checkFormat( &file ); 209 bool ok = mFormat->checkFormat( &file );
210 file.close(); 210 file.close();
211 211
212 return ok; 212 return ok;
213 } 213 }
214} 214}
215 215
216void ResourceFile::doClose() 216void ResourceFile::doClose()
217{ 217{
218} 218}
219 219
220bool ResourceFile::load() 220bool ResourceFile::load()
221{ 221{
222 222
223 QFile file( fileName() ); 223 QFile file( fileName() );
224 if ( !file.open( IO_ReadOnly ) ) { 224 if ( !file.open( IO_ReadOnly ) ) {
225 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) ); 225 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) );
226 return false; 226 return false;
227 } 227 }
228 228
229// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); 229// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
230 230
231 return mFormat->loadAll( addressBook(), this, &file ); 231 return mFormat->loadAll( addressBook(), this, &file );
232} 232}
233 233
234bool ResourceFile::save( Ticket *ticket ) 234bool ResourceFile::save( Ticket *ticket )
235{ 235{
236// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); 236// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
237 237
238 238
239 // create backup file 239 // create backup file
240 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 240 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
241 241
242/*US we use a simpler method to create a backupfile 242/*US we use a simpler method to create a backupfile
243 243
244 (void) KSaveFile::backupFile( mFileName, QString::null 244 (void) KSaveFile::backupFile( mFileName, QString::null
245 ,extension ); 245 ,extension );
246 246
247 KSaveFile saveFile( mFileName ); 247 KSaveFile saveFile( mFileName );
248 bool ok = false; 248 bool ok = false;
249 if ( saveFile.status() == 0 && saveFile.file() ) 249 if ( saveFile.status() == 0 && saveFile.file() )
250 { 250 {
251 mFormat->saveAll( addressBook(), this, saveFile.file() ); 251 mFormat->saveAll( addressBook(), this, saveFile.file() );
252 ok = saveFile.close(); 252 ok = saveFile.close();