author | ulf69 <ulf69> | 2004-07-17 00:39:36 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-17 00:39:36 (UTC) |
commit | cb3782d17ea98a15acb158ea6dd18aa2600b08f8 (patch) (unidiff) | |
tree | 36fa94a526fb3afb73fe2bd1ba511af0c2174aab | |
parent | 01570860c92be8977a1ba558ae7c5f15d4635851 (diff) | |
download | kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.zip kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.tar.gz kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.tar.bz2 |
implementation of the sharp resource module
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 90 |
1 files changed, 46 insertions, 44 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 347d51c..31b99ca 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -49,7 +49,7 @@ $Id$ | |||
49 | #include "resourcesharpdtmconfig.h" | 49 | #include "resourcesharpdtmconfig.h" |
50 | #include "stdaddressbook.h" | 50 | #include "resourcesharpdtm.h" |
51 | 51 | ||
52 | //#include "qtopiaconverter.h" | 52 | #include "stdaddressbook.h" |
53 | 53 | ||
54 | #include "resourcesharpdtm.h" | 54 | #include "sharpdtmconverter.h" |
55 | 55 | ||
@@ -69,3 +69,3 @@ ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) | |||
69 | 69 | ||
70 | QString fileName = SlZDataBase::addressbookFileName(); | 70 | QString fileName = SlZDataBase::addressbookFileName(); |
71 | init( fileName ); | 71 | init( fileName ); |
@@ -140,3 +140,3 @@ bool ResourceSharpDTM::doOpen() | |||
140 | bool ok = true; | 140 | bool ok = true; |
141 | 141 | ||
142 | file.close(); | 142 | file.close(); |
@@ -146,3 +146,3 @@ bool ResourceSharpDTM::doOpen() | |||
146 | */ | 146 | */ |
147 | return true; | 147 | return true; |
148 | } | 148 | } |
@@ -158,5 +158,7 @@ bool ResourceSharpDTM::load() | |||
158 | // qDebug("ResourceSharpDTM::load: Try to load file() %s", mFileName.latin1()); | 158 | // qDebug("ResourceSharpDTM::load: Try to load file() %s", mFileName.latin1()); |
159 | 159 | ||
160 | // the last parameter in the SlZDataBase constructor means "readonly" | ||
160 | SlZDataBase* access = new SlZDataBase(mFileName, | 161 | SlZDataBase* access = new SlZDataBase(mFileName, |
161 | SlZDataBase::addressbookItems()); | 162 | SlZDataBase::addressbookItems(), |
163 | NULL, true); | ||
162 | if ( !access ) { | 164 | if ( !access ) { |
@@ -166,3 +168,3 @@ bool ResourceSharpDTM::load() | |||
166 | } | 168 | } |
167 | 169 | ||
168 | bool res = false; | 170 | bool res = false; |
@@ -170,9 +172,10 @@ bool ResourceSharpDTM::load() | |||
170 | { | 172 | { |
171 | // mConverter = new QtopiaConverter(); | 173 | mConverter = new SharpDTMConverter(); |
172 | // res = mConverter->init(); | 174 | res = mConverter->init(); |
173 | res = true; | ||
174 | if ( !res ) | 175 | if ( !res ) |
175 | { | 176 | { |
176 | qDebug("Unable to initialize qtopia converter. Most likely a problem with the category file"); | 177 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); |
177 | addressBook()->error( i18n( "Unable to initialize qtopia converter. Most likely a problem with the category file" ) ); | 178 | |
179 | qDebug(msg); | ||
180 | addressBook()->error( i18n( msg ) ); | ||
178 | delete access; | 181 | delete access; |
@@ -181,14 +184,13 @@ bool ResourceSharpDTM::load() | |||
181 | } | 184 | } |
182 | /* | 185 | |
183 | { //create a new scope | 186 | { //create a new scope |
184 | AddressBookIterator it(*access); | 187 | CardId id; |
185 | const PimContact* contact; | 188 | |
186 | 189 | for (bool res=access->first(); res == true; res=access->next()) { | |
187 | for (contact=it.toFirst(); it.current(); ++it) { | 190 | id = access->cardId(); |
188 | contact = it.current(); | 191 | |
189 | |||
190 | KABC::Addressee addressee; | 192 | KABC::Addressee addressee; |
191 | 193 | ||
192 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); | 194 | res = mConverter->sharpToAddressee( id, access, addressee ); |
193 | 195 | ||
194 | if ( !addressee.isEmpty() && res ) | 196 | if ( !addressee.isEmpty() && res ) |
@@ -200,3 +202,3 @@ bool ResourceSharpDTM::load() | |||
200 | } | 202 | } |
201 | */ | 203 | |
202 | delete access; | 204 | delete access; |
@@ -213,5 +215,5 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
213 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | 215 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); |
214 | 216 | ||
215 | /*US we use a simpler method to create a backupfile | 217 | /*US we use a simpler method to create a backupfile |
216 | 218 | ||
217 | (void) KSaveFile::backupFile( mFileName, QString::null | 219 | (void) KSaveFile::backupFile( mFileName, QString::null |
@@ -229,3 +231,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
229 | /*US | 231 | /*US |
230 | //US ToDo: write backupfile | 232 | //US ToDo: write backupfile |
231 | QFile info; | 233 | QFile info; |
@@ -235,3 +237,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
235 | //US mFormat->saveAll( addressBook(), this, &info ); | 237 | //US mFormat->saveAll( addressBook(), this, &info ); |
236 | 238 | ||
237 | info.close(); | 239 | info.close(); |
@@ -240,11 +242,11 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
240 | else { | 242 | else { |
241 | 243 | ||
242 | } | 244 | } |
243 | 245 | ||
244 | if ( !ok ) | 246 | if ( !ok ) |
245 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); | 247 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); |
246 | 248 | ||
247 | delete ticket; | 249 | delete ticket; |
248 | unlock( mFileName ); | 250 | unlock( mFileName ); |
249 | 251 | ||
250 | return ok; | 252 | return ok; |
@@ -252,3 +254,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
252 | qDebug("ResourceQtopia::save has to be changed"); | 254 | qDebug("ResourceQtopia::save has to be changed"); |
253 | */ | 255 | */ |
254 | return true; | 256 | return true; |
@@ -265,6 +267,6 @@ bool ResourceSharpDTM::lock( const QString &fileName ) | |||
265 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | 267 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); |
266 | 268 | ||
267 | KURL url(fn); | 269 | KURL url(fn); |
268 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 270 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
269 | 271 | ||
270 | kdDebug(5700) << "-- lock name: " << lockName << endl; | 272 | kdDebug(5700) << "-- lock name: " << lockName << endl; |
@@ -275,4 +277,4 @@ bool ResourceSharpDTM::lock( const QString &fileName ) | |||
275 | lockUniqueName = fn + KApplication::randomString( 8 ); | 277 | lockUniqueName = fn + KApplication::randomString( 8 ); |
276 | 278 | ||
277 | url = lockUniqueName; | 279 | url = lockUniqueName; |
278 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | 280 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); |
@@ -307,5 +309,5 @@ void ResourceSharpDTM::unlock( const QString &fileName ) | |||
307 | //US QString lockName = fn + ".lock"; | 309 | //US QString lockName = fn + ".lock"; |
308 | KURL url(fn); | 310 | KURL url(fn); |
309 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 311 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
310 | 312 | ||
311 | QFile::remove( lockName ); | 313 | QFile::remove( lockName ); |
@@ -319,3 +321,3 @@ void ResourceSharpDTM::setFileName( const QString &fileName ) | |||
319 | mDirWatch.removeFile( mFileName ); | 321 | mDirWatch.removeFile( mFileName ); |
320 | 322 | ||
321 | mFileName = fileName; | 323 | mFileName = fileName; |
@@ -338,3 +340,3 @@ void ResourceSharpDTM::fileChanged() | |||
338 | return; | 340 | return; |
339 | 341 | ||
340 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); | 342 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); |