summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp67
1 files changed, 34 insertions, 33 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 7475685..7e10e46 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -67,5 +67,5 @@ ResourceQtopia::ResourceQtopia( const KConfig *config )
67 // we can not choose the filename. Therefore use the default to display 67 // we can not choose the filename. Therefore use the default to display
68 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 68 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
69 69
70 init( fileName ); 70 init( fileName );
71} 71}
@@ -138,5 +138,5 @@ bool ResourceQtopia::doOpen()
138//US bool ok = mFormat->checkFormat( &file ); 138//US bool ok = mFormat->checkFormat( &file );
139 bool ok = true; 139 bool ok = true;
140 140
141 file.close(); 141 file.close();
142 142
@@ -144,5 +144,5 @@ bool ResourceQtopia::doOpen()
144 } 144 }
145*/ 145*/
146 return true; 146 return true;
147} 147}
148 148
@@ -156,5 +156,5 @@ bool ResourceQtopia::load()
156 156
157// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1()); 157// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1());
158 158
159 AddressBookAccess* access = new AddressBookAccess(); 159 AddressBookAccess* access = new AddressBookAccess();
160 160
@@ -164,5 +164,5 @@ bool ResourceQtopia::load()
164 return false; 164 return false;
165 } 165 }
166 166
167 bool res = false; 167 bool res = false;
168 if (mConverter == 0) 168 if (mConverter == 0)
@@ -172,12 +172,13 @@ bool ResourceQtopia::load()
172 if ( !res ) 172 if ( !res )
173 { 173 {
174 qDebug("Unable to initialize qtopia converter. Most likely a problem with the category file"); 174 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
175 addressBook()->error( i18n( "Unable to initialize qtopia converter. Most likely a problem with the category file" ) ); 175 qDebug(msg);
176 addressBook()->error( i18n( msg ) );
176 delete access; 177 delete access;
177 return false; 178 return false;
178 } 179 }
179 } 180 }
180 181
181 { //create a new scope 182 { //create a new scope
182 AddressBookIterator it(*access); 183 AddressBookIterator it(*access);
183 const PimContact* contact; 184 const PimContact* contact;
@@ -185,9 +186,9 @@ bool ResourceQtopia::load()
185 for (contact=it.toFirst(); it.current(); ++it) { 186 for (contact=it.toFirst(); it.current(); ++it) {
186 contact = it.current(); 187 contact = it.current();
187 188
188 KABC::Addressee addressee; 189 KABC::Addressee addressee;
189 190
190 res = mConverter->qtopiaToAddressee( (*contact), addressee ); 191 res = mConverter->qtopiaToAddressee( (*contact), addressee );
191 192
192 if ( !addressee.isEmpty() && res ) 193 if ( !addressee.isEmpty() && res )
193 { 194 {
@@ -197,5 +198,5 @@ bool ResourceQtopia::load()
197 } 198 }
198 } 199 }
199 200
200 delete access; 201 delete access;
201 return true; 202 return true;
@@ -210,7 +211,7 @@ bool ResourceQtopia::save( Ticket *ticket )
210 // create backup file 211 // create backup file
211 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 212 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
212 213
213/*US we use a simpler method to create a backupfile 214/*US we use a simpler method to create a backupfile
214 215
215 (void) KSaveFile::backupFile( mFileName, QString::null 216 (void) KSaveFile::backupFile( mFileName, QString::null
216 ,extension ); 217 ,extension );
@@ -226,5 +227,5 @@ bool ResourceQtopia::save( Ticket *ticket )
226 227
227/*US 228/*US
228//US ToDo: write backupfile 229//US ToDo: write backupfile
229 QFile info; 230 QFile info;
230 info.setName( mFileName ); 231 info.setName( mFileName );
@@ -232,22 +233,22 @@ bool ResourceQtopia::save( Ticket *ticket )
232 if ( ok ) { 233 if ( ok ) {
233//US mFormat->saveAll( addressBook(), this, &info ); 234//US mFormat->saveAll( addressBook(), this, &info );
234 235
235 info.close(); 236 info.close();
236 ok = true; 237 ok = true;
237 } 238 }
238 else { 239 else {
239 240
240 } 241 }
241 242
242 if ( !ok ) 243 if ( !ok )
243 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 244 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
244 245
245 delete ticket; 246 delete ticket;
246 unlock( mFileName ); 247 unlock( mFileName );
247 248
248 return ok; 249 return ok;
249 250
250 qDebug("ResourceQtopia::save has to be changed"); 251 qDebug("ResourceQtopia::save has to be changed");
251*/ 252*/
252 return true; 253 return true;
253} 254}
@@ -262,8 +263,8 @@ bool ResourceQtopia::lock( const QString &fileName )
262//US fn.replace( QRegExp("/"), "_" ); 263//US fn.replace( QRegExp("/"), "_" );
263//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 264//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
264 265
265 KURL url(fn); 266 KURL url(fn);
266 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 267 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
267 268
268 kdDebug(5700) << "-- lock name: " << lockName << endl; 269 kdDebug(5700) << "-- lock name: " << lockName << endl;
269 270
@@ -272,6 +273,6 @@ bool ResourceQtopia::lock( const QString &fileName )
272 QString lockUniqueName; 273 QString lockUniqueName;
273 lockUniqueName = fn + KApplication::randomString( 8 ); 274 lockUniqueName = fn + KApplication::randomString( 8 );
274 275
275 url = lockUniqueName; 276 url = lockUniqueName;
276//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 277//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
277 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 278 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
@@ -304,7 +305,7 @@ void ResourceQtopia::unlock( const QString &fileName )
304//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 305//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
305//US QString lockName = fn + ".lock"; 306//US QString lockName = fn + ".lock";
306 KURL url(fn); 307 KURL url(fn);
307 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 308 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
308 309
309 QFile::remove( lockName ); 310 QFile::remove( lockName );
310 QFile::remove( mLockUniqueName ); 311 QFile::remove( mLockUniqueName );
@@ -316,5 +317,5 @@ void ResourceQtopia::setFileName( const QString &fileName )
316 mDirWatch.stopScan(); 317 mDirWatch.stopScan();
317 mDirWatch.removeFile( mFileName ); 318 mDirWatch.removeFile( mFileName );
318 319
319 mFileName = fileName; 320 mFileName = fileName;
320 321
@@ -322,5 +323,5 @@ void ResourceQtopia::setFileName( const QString &fileName )
322 mDirWatch.startScan(); 323 mDirWatch.startScan();
323 324
324//US simulate KDirWatch event 325//US simulate KDirWatch event
325//US fileChanged(); 326//US fileChanged();
326} 327}
@@ -337,5 +338,5 @@ void ResourceQtopia::fileChanged()
337 if (!addressBook()) 338 if (!addressBook())
338 return; 339 return;
339 340
340 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); 341 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
341 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 342 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {