-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 67 |
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 | |||
@@ -68,3 +68,3 @@ ResourceQtopia::ResourceQtopia( const KConfig *config ) | |||
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 ); |
@@ -139,3 +139,3 @@ bool ResourceQtopia::doOpen() | |||
139 | bool ok = true; | 139 | bool ok = true; |
140 | 140 | ||
141 | file.close(); | 141 | file.close(); |
@@ -145,3 +145,3 @@ bool ResourceQtopia::doOpen() | |||
145 | */ | 145 | */ |
146 | return true; | 146 | return true; |
147 | } | 147 | } |
@@ -157,3 +157,3 @@ bool ResourceQtopia::load() | |||
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(); |
@@ -165,3 +165,3 @@ bool ResourceQtopia::load() | |||
165 | } | 165 | } |
166 | 166 | ||
167 | bool res = false; | 167 | bool res = false; |
@@ -173,4 +173,5 @@ bool ResourceQtopia::load() | |||
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; |
@@ -179,4 +180,4 @@ bool ResourceQtopia::load() | |||
179 | } | 180 | } |
180 | 181 | ||
181 | { //create a new scope | 182 | { //create a new scope |
182 | AddressBookIterator it(*access); | 183 | AddressBookIterator it(*access); |
@@ -186,7 +187,7 @@ bool ResourceQtopia::load() | |||
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 ) |
@@ -198,3 +199,3 @@ bool ResourceQtopia::load() | |||
198 | } | 199 | } |
199 | 200 | ||
200 | delete access; | 201 | delete access; |
@@ -211,5 +212,5 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
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 |
@@ -227,3 +228,3 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
227 | /*US | 228 | /*US |
228 | //US ToDo: write backupfile | 229 | //US ToDo: write backupfile |
229 | QFile info; | 230 | QFile info; |
@@ -233,3 +234,3 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
233 | //US mFormat->saveAll( addressBook(), this, &info ); | 234 | //US mFormat->saveAll( addressBook(), this, &info ); |
234 | 235 | ||
235 | info.close(); | 236 | info.close(); |
@@ -238,11 +239,11 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
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; |
@@ -250,3 +251,3 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
250 | qDebug("ResourceQtopia::save has to be changed"); | 251 | qDebug("ResourceQtopia::save has to be changed"); |
251 | */ | 252 | */ |
252 | return true; | 253 | return true; |
@@ -263,6 +264,6 @@ bool ResourceQtopia::lock( const QString &fileName ) | |||
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; |
@@ -273,4 +274,4 @@ bool ResourceQtopia::lock( const QString &fileName ) | |||
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 ); |
@@ -305,5 +306,5 @@ void ResourceQtopia::unlock( const QString &fileName ) | |||
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 ); |
@@ -317,3 +318,3 @@ void ResourceQtopia::setFileName( const QString &fileName ) | |||
317 | mDirWatch.removeFile( mFileName ); | 318 | mDirWatch.removeFile( mFileName ); |
318 | 319 | ||
319 | mFileName = fileName; | 320 | mFileName = fileName; |
@@ -323,3 +324,3 @@ void ResourceQtopia::setFileName( const QString &fileName ) | |||
323 | 324 | ||
324 | //US simulate KDirWatch event | 325 | //US simulate KDirWatch event |
325 | //US fileChanged(); | 326 | //US fileChanged(); |
@@ -338,3 +339,3 @@ void ResourceQtopia::fileChanged() | |||
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 ) ); |