summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-03 21:47:33 (UTC)
committer zautrix <zautrix>2004-07-03 21:47:33 (UTC)
commit5e59162e6eb6603610d1ca4c96d5d97acae0f60b (patch) (unidiff)
treec891d1e2125cf6f68509332fe06c878709525480
parent54e76d203297aa5da51342492d482187f4d6cd20 (diff)
downloadkdepimpi-5e59162e6eb6603610d1ca4c96d5d97acae0f60b.zip
kdepimpi-5e59162e6eb6603610d1ca4c96d5d97acae0f60b.tar.gz
kdepimpi-5e59162e6eb6603610d1ca4c96d5d97acae0f60b.tar.bz2
Fixed crash when accessing opie resource
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/opie/resourceopie.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index a4f8d8a..3b2a6b7 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -158,129 +158,130 @@ bool ResourceOpie::doOpen()
158 file.close(); 158 file.close();
159 return true; 159 return true;
160 } 160 }
161 161
162//US bool ok = mFormat->checkFormat( &file ); 162//US bool ok = mFormat->checkFormat( &file );
163 bool ok = true; 163 bool ok = true;
164 164
165 file.close(); 165 file.close();
166 166
167 return ok; 167 return ok;
168 } 168 }
169*/ 169*/
170 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1()); 170 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
171 return true; 171 return true;
172} 172}
173 173
174void ResourceOpie::doClose() 174void ResourceOpie::doClose()
175{ 175{
176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); 176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
177} 177}
178 178
179bool ResourceOpie::load() 179bool ResourceOpie::load()
180{ 180{
181// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 181// qDebug("ResourceOpie::load() %s", mFileName.latin1());
182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
183 183
184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1()); 184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
185 185
186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName ); 186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false); 187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
188 188
189 if ( !access ) { 189 if ( !access ) {
190 qDebug("Unable to load file() %s", mFileName.latin1()); 190 qDebug("Unable to load file() %s", mFileName.latin1());
191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); 191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
192 return false; 192 return false;
193 } 193 }
194 194
195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
196 196
197 if (mConverter == 0) 197 if (mConverter == 0)
198 mConverter = new OpieConverter(); 198 mConverter = new OpieConverter();
199 199
200 200
201 OContactAccess::List::Iterator it; 201 OContactAccess::List::Iterator it;
202 OContactAccess::List allList = access->allRecords(); 202 OContactAccess::List allList = access->allRecords();
203 bool res = false; 203 bool res = false;
204 for ( it = allList.begin(); it != allList.end(); ++it ) 204 for ( it = allList.begin(); it != allList.end(); ++it )
205 { 205 {
206 OContact c = (*it); 206 OContact c = (*it);
207 207
208 KABC::Addressee addressee; 208 KABC::Addressee addressee;
209 209
210 res = mConverter->opieToAddressee( c, addressee ); 210 res = mConverter->opieToAddressee( c, addressee );
211 211
212 if ( !addressee.isEmpty() && res ) 212 if ( !addressee.isEmpty() && res )
213 { 213 {
214 addressee.setResource( this ); 214 addressee.setResource( this );
215 addressBook()->insertAddressee( addressee ); 215 addressBook()->insertAddressee( addressee );
216 } 216 }
217 217
218// qDebug("found %s", c.fullName().latin1()); 218// qDebug("found %s", c.fullName().latin1());
219 } 219 }
220 220
221 delete access; 221 delete access;
222 delete backend; 222 // it seems so, that deletion of access deletes backend as well
223 //delete backend;
223 224
224 return true; 225 return true;
225} 226}
226 227
227bool ResourceOpie::save( Ticket *ticket ) 228bool ResourceOpie::save( Ticket *ticket )
228{ 229{
229 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); 230 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
230/*US 231/*US
231 232
232 qDebug("ResourceOpie::save %s", mFileName.latin1()); 233 qDebug("ResourceOpie::save %s", mFileName.latin1());
233 kdDebug(5700) << "ResourceOpie::save()" << endl; 234 kdDebug(5700) << "ResourceOpie::save()" << endl;
234 235
235 // create backup file 236 // create backup file
236 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 237 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
237*/ 238*/
238/*US we use a simpler method to create a backupfile 239/*US we use a simpler method to create a backupfile
239 240
240 (void) KSaveFile::backupFile( mFileName, QString::null 241 (void) KSaveFile::backupFile( mFileName, QString::null
241 ,extension ); 242 ,extension );
242 243
243 KSaveFile saveFile( mFileName ); 244 KSaveFile saveFile( mFileName );
244 bool ok = false; 245 bool ok = false;
245 if ( saveFile.status() == 0 && saveFile.file() ) 246 if ( saveFile.status() == 0 && saveFile.file() )
246 { 247 {
247 mFormat->saveAll( addressBook(), this, saveFile.file() ); 248 mFormat->saveAll( addressBook(), this, saveFile.file() );
248 ok = saveFile.close(); 249 ok = saveFile.close();
249 } 250 }
250*/ 251*/
251/*US 252/*US
252//US ToDo: write backupfile 253//US ToDo: write backupfile
253 QFile info; 254 QFile info;
254 info.setName( mFileName ); 255 info.setName( mFileName );
255 bool ok = info.open( IO_WriteOnly ); 256 bool ok = info.open( IO_WriteOnly );
256 if ( ok ) { 257 if ( ok ) {
257//US mFormat->saveAll( addressBook(), this, &info ); 258//US mFormat->saveAll( addressBook(), this, &info );
258 259
259 info.close(); 260 info.close();
260 ok = true; 261 ok = true;
261 } 262 }
262 else { 263 else {
263 264
264 } 265 }
265 266
266 if ( !ok ) 267 if ( !ok )
267 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 268 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
268 269
269 delete ticket; 270 delete ticket;
270 unlock( mFileName ); 271 unlock( mFileName );
271 272
272 return ok; 273 return ok;
273 274
274 qDebug("ResourceOpie::save has to be changed"); 275 qDebug("ResourceOpie::save has to be changed");
275*/ 276*/
276 return true; 277 return true;
277 278
278} 279}
279 280
280bool ResourceOpie::lock( const QString &fileName ) 281bool ResourceOpie::lock( const QString &fileName )
281{ 282{
282 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1()); 283 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1());
283 284
284/*US 285/*US
285// qDebug("ResourceOpie::lock() %s", fileName.latin1()); 286// qDebug("ResourceOpie::lock() %s", fileName.latin1());
286 kdDebug(5700) << "ResourceOpie::lock()" << endl; 287 kdDebug(5700) << "ResourceOpie::lock()" << endl;