-rw-r--r-- | kabc/addressbook.cpp | 2 | ||||
-rw-r--r-- | kabc/kabcE.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 7 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.h | 2 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 16 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.h | 4 | ||||
-rw-r--r-- | kabc/plugins/ldap/resourceldap.cpp | 7 | ||||
-rw-r--r-- | kabc/plugins/ldap/resourceldap.h | 2 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 11 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.h | 4 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 11 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.h | 4 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 8 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.h | 4 | ||||
-rw-r--r-- | kabc/resource.cpp | 32 | ||||
-rw-r--r-- | kabc/resource.h | 16 |
16 files changed, 39 insertions, 93 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 592d78d..c584c35 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -152,257 +152,257 @@ bool AddressBook::Iterator::operator!=( const Iterator &it ) | |||
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
398 | } | 398 | } |
399 | KABC::VCardConverter converter; | 399 | KABC::VCardConverter converter; |
400 | QString vcard; | 400 | QString vcard; |
401 | //Resource *resource() const; | 401 | //Resource *resource() const; |
402 | converter.addresseeToVCard( *it, vcard, version ); | 402 | converter.addresseeToVCard( *it, vcard, version ); |
403 | t << vcard << "\r\n"; | 403 | t << vcard << "\r\n"; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
407 | outFile.close(); | 407 | outFile.close(); |
408 | } | 408 | } |
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro index 061909b..96fe39e 100644 --- a/kabc/kabcE.pro +++ b/kabc/kabcE.pro | |||
@@ -1,198 +1,196 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = kamicrokabc | 3 | TARGET = kamicrokabc |
4 | 4 | ||
5 | 5 | ||
6 | INCLUDEPATH += . $(KDEPIMDIR) vcard/include vcard/include/generated $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/libkdepim $(KDEPIMDIR)/qtcompat $(QPEDIR)/include | 6 | INCLUDEPATH += . $(KDEPIMDIR) vcard/include vcard/include/generated $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/libkdepim $(KDEPIMDIR)/qtcompat $(QPEDIR)/include |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde | 10 | LIBS += -lmicrokde |
11 | LIBS += -lmicrokdepim | 11 | LIBS += -lmicrokdepim |
12 | #LIBS += -lldap | 12 | #LIBS += -lldap |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | DEFINES += KAB_EMBEDDED | 14 | DEFINES += KAB_EMBEDDED |
15 | 15 | ||
16 | #enable the following line if you want to get debugoutput while loading adresses | 16 | #enable the following line if you want to get debugoutput while loading adresses |
17 | #DEFINES += VCARD_DEBUG | 17 | #DEFINES += VCARD_DEBUG |
18 | 18 | ||
19 | INTERFACES = \ | 19 | INTERFACES = \ |
20 | 20 | ||
21 | HEADERS = \ | 21 | HEADERS = \ |
22 | address.h \ | 22 | address.h \ |
23 | addressbook.h \ | 23 | addressbook.h \ |
24 | addressee.h \ | 24 | addressee.h \ |
25 | addresseedialog.h \ | 25 | addresseedialog.h \ |
26 | addresseelist.h \ | 26 | addresseelist.h \ |
27 | addresseeview.h \ | 27 | addresseeview.h \ |
28 | agent.h \ | 28 | agent.h \ |
29 | distributionlist.h \ | 29 | distributionlist.h \ |
30 | distributionlistdialog.h \ | 30 | distributionlistdialog.h \ |
31 | distributionlisteditor.h \ | 31 | distributionlisteditor.h \ |
32 | field.h \ | 32 | field.h \ |
33 | formatfactory.h \ | 33 | formatfactory.h \ |
34 | formatplugin.h \ | 34 | formatplugin.h \ |
35 | geo.h \ | 35 | geo.h \ |
36 | key.h \ | 36 | key.h \ |
37 | phonenumber.h \ | 37 | phonenumber.h \ |
38 | picture.h \ | 38 | picture.h \ |
39 | plugin.h \ | 39 | plugin.h \ |
40 | resource.h \ | 40 | resource.h \ |
41 | secrecy.h \ | 41 | secrecy.h \ |
42 | sound.h \ | 42 | sound.h \ |
43 | stdaddressbook.h \ | 43 | stdaddressbook.h \ |
44 | syncprefwidget.h \ | ||
45 | timezone.h \ | 44 | timezone.h \ |
46 | tmpaddressbook.h \ | 45 | tmpaddressbook.h \ |
47 | vcardconverter.h \ | 46 | vcardconverter.h \ |
48 | vcard21parser.h \ | 47 | vcard21parser.h \ |
49 | vcardformatimpl.h \ | 48 | vcardformatimpl.h \ |
50 | vcardformatplugin.h \ | 49 | vcardformatplugin.h \ |
51 | vcardparser/vcardline.h \ | 50 | vcardparser/vcardline.h \ |
52 | vcardparser/vcard.h \ | 51 | vcardparser/vcard.h \ |
53 | vcardparser/vcardtool.h \ | 52 | vcardparser/vcardtool.h \ |
54 | vcardparser/vcardparser.h \ | 53 | vcardparser/vcardparser.h \ |
55 | vcard/include/VCardAdrParam.h \ | 54 | vcard/include/VCardAdrParam.h \ |
56 | vcard/include/VCardAdrValue.h \ | 55 | vcard/include/VCardAdrValue.h \ |
57 | vcard/include/VCardAgentParam.h \ | 56 | vcard/include/VCardAgentParam.h \ |
58 | vcard/include/VCardContentLine.h \ | 57 | vcard/include/VCardContentLine.h \ |
59 | vcard/include/VCardDateParam.h \ | 58 | vcard/include/VCardDateParam.h \ |
60 | vcard/include/VCardDateValue.h \ | 59 | vcard/include/VCardDateValue.h \ |
61 | vcard/include/VCardEmailParam.h \ | 60 | vcard/include/VCardEmailParam.h \ |
62 | vcard/include/VCardGeoValue.h \ | 61 | vcard/include/VCardGeoValue.h \ |
63 | vcard/include/VCardGroup.h \ | 62 | vcard/include/VCardGroup.h \ |
64 | vcard/include/VCardImageParam.h \ | 63 | vcard/include/VCardImageParam.h \ |
65 | vcard/include/VCardImageValue.h \ | 64 | vcard/include/VCardImageValue.h \ |
66 | vcard/include/VCardLangValue.h \ | 65 | vcard/include/VCardLangValue.h \ |
67 | vcard/include/VCardNValue.h \ | 66 | vcard/include/VCardNValue.h \ |
68 | vcard/include/VCardParam.h \ | 67 | vcard/include/VCardParam.h \ |
69 | vcard/include/VCardPhoneNumberValue.h \ | 68 | vcard/include/VCardPhoneNumberValue.h \ |
70 | vcard/include/VCardSourceParam.h \ | 69 | vcard/include/VCardSourceParam.h \ |
71 | vcard/include/VCardTelParam.h \ | 70 | vcard/include/VCardTelParam.h \ |
72 | vcard/include/VCardTextParam.h \ | 71 | vcard/include/VCardTextParam.h \ |
73 | vcard/include/VCardTextNSParam.h \ | 72 | vcard/include/VCardTextNSParam.h \ |
74 | vcard/include/VCardTextValue.h \ | 73 | vcard/include/VCardTextValue.h \ |
75 | vcard/include/VCardTextBinParam.h \ | 74 | vcard/include/VCardTextBinParam.h \ |
76 | vcard/include/VCardURIValue.h \ | 75 | vcard/include/VCardURIValue.h \ |
77 | vcard/include/VCardVCard.h \ | 76 | vcard/include/VCardVCard.h \ |
78 | vcard/include/VCardEntity.h \ | 77 | vcard/include/VCardEntity.h \ |
79 | vcard/include/VCardValue.h \ | 78 | vcard/include/VCardValue.h \ |
80 | vcard/include/VCardSoundValue.h \ | 79 | vcard/include/VCardSoundValue.h \ |
81 | vcard/include/VCardAgentValue.h \ | 80 | vcard/include/VCardAgentValue.h \ |
82 | vcard/include/VCardTelValue.h \ | 81 | vcard/include/VCardTelValue.h \ |
83 | vcard/include/VCardTextBinValue.h \ | 82 | vcard/include/VCardTextBinValue.h \ |
84 | vcard/include/VCardOrgValue.h \ | 83 | vcard/include/VCardOrgValue.h \ |
85 | vcard/include/VCardUTCValue.h \ | 84 | vcard/include/VCardUTCValue.h \ |
86 | vcard/include/VCardClassValue.h \ | 85 | vcard/include/VCardClassValue.h \ |
87 | vcard/include/VCardFloatValue.h \ | 86 | vcard/include/VCardFloatValue.h \ |
88 | vcard/include/VCardTextListValue.h \ | 87 | vcard/include/VCardTextListValue.h \ |
89 | vcard/include/generated/AdrParam-generated.h \ | 88 | vcard/include/generated/AdrParam-generated.h \ |
90 | vcard/include/generated/AdrValue-generated.h \ | 89 | vcard/include/generated/AdrValue-generated.h \ |
91 | vcard/include/generated/AgentParam-generated.h \ | 90 | vcard/include/generated/AgentParam-generated.h \ |
92 | vcard/include/generated/ContentLine-generated.h \ | 91 | vcard/include/generated/ContentLine-generated.h \ |
93 | vcard/include/generated/DateParam-generated.h \ | 92 | vcard/include/generated/DateParam-generated.h \ |
94 | vcard/include/generated/DateValue-generated.h \ | 93 | vcard/include/generated/DateValue-generated.h \ |
95 | vcard/include/generated/EmailParam-generated.h \ | 94 | vcard/include/generated/EmailParam-generated.h \ |
96 | vcard/include/generated/GeoValue-generated.h \ | 95 | vcard/include/generated/GeoValue-generated.h \ |
97 | vcard/include/generated/Group-generated.h \ | 96 | vcard/include/generated/Group-generated.h \ |
98 | vcard/include/generated/ImageParam-generated.h \ | 97 | vcard/include/generated/ImageParam-generated.h \ |
99 | vcard/include/generated/ImageValue-generated.h \ | 98 | vcard/include/generated/ImageValue-generated.h \ |
100 | vcard/include/generated/LangValue-generated.h \ | 99 | vcard/include/generated/LangValue-generated.h \ |
101 | vcard/include/generated/NValue-generated.h \ | 100 | vcard/include/generated/NValue-generated.h \ |
102 | vcard/include/generated/Param-generated.h \ | 101 | vcard/include/generated/Param-generated.h \ |
103 | vcard/include/generated/PhoneNumberValue-generated.h \ | 102 | vcard/include/generated/PhoneNumberValue-generated.h \ |
104 | vcard/include/generated/SourceParam-generated.h \ | 103 | vcard/include/generated/SourceParam-generated.h \ |
105 | vcard/include/generated/TelParam-generated.h \ | 104 | vcard/include/generated/TelParam-generated.h \ |
106 | vcard/include/generated/TextParam-generated.h \ | 105 | vcard/include/generated/TextParam-generated.h \ |
107 | vcard/include/generated/TextNSParam-generated.h \ | 106 | vcard/include/generated/TextNSParam-generated.h \ |
108 | vcard/include/generated/TextValue-generated.h \ | 107 | vcard/include/generated/TextValue-generated.h \ |
109 | vcard/include/generated/TextBinParam-generated.h \ | 108 | vcard/include/generated/TextBinParam-generated.h \ |
110 | vcard/include/generated/URIValue-generated.h \ | 109 | vcard/include/generated/URIValue-generated.h \ |
111 | vcard/include/generated/VCard-generated.h \ | 110 | vcard/include/generated/VCard-generated.h \ |
112 | vcard/include/generated/VCardEntity-generated.h \ | 111 | vcard/include/generated/VCardEntity-generated.h \ |
113 | vcard/include/generated/Value-generated.h \ | 112 | vcard/include/generated/Value-generated.h \ |
114 | vcard/include/generated/SoundValue-generated.h \ | 113 | vcard/include/generated/SoundValue-generated.h \ |
115 | vcard/include/generated/AgentValue-generated.h \ | 114 | vcard/include/generated/AgentValue-generated.h \ |
116 | vcard/include/generated/TelValue-generated.h \ | 115 | vcard/include/generated/TelValue-generated.h \ |
117 | vcard/include/generated/TextBinValue-generated.h \ | 116 | vcard/include/generated/TextBinValue-generated.h \ |
118 | vcard/include/generated/OrgValue-generated.h \ | 117 | vcard/include/generated/OrgValue-generated.h \ |
119 | vcard/include/generated/UTCValue-generated.h \ | 118 | vcard/include/generated/UTCValue-generated.h \ |
120 | vcard/include/generated/ClassValue-generated.h \ | 119 | vcard/include/generated/ClassValue-generated.h \ |
121 | vcard/include/generated/FloatValue-generated.h \ | 120 | vcard/include/generated/FloatValue-generated.h \ |
122 | vcard/include/generated/TextListValue-generated.h | 121 | vcard/include/generated/TextListValue-generated.h |
123 | 122 | ||
124 | 123 | ||
125 | 124 | ||
126 | 125 | ||
127 | SOURCES = \ | 126 | SOURCES = \ |
128 | address.cpp \ | 127 | address.cpp \ |
129 | addressbook.cpp \ | 128 | addressbook.cpp \ |
130 | addressee.cpp \ | 129 | addressee.cpp \ |
131 | addresseedialog.cpp \ | 130 | addresseedialog.cpp \ |
132 | addresseelist.cpp \ | 131 | addresseelist.cpp \ |
133 | addresseeview.cpp \ | 132 | addresseeview.cpp \ |
134 | agent.cpp \ | 133 | agent.cpp \ |
135 | distributionlist.cpp \ | 134 | distributionlist.cpp \ |
136 | distributionlistdialog.cpp \ | 135 | distributionlistdialog.cpp \ |
137 | distributionlisteditor.cpp \ | 136 | distributionlisteditor.cpp \ |
138 | field.cpp \ | 137 | field.cpp \ |
139 | formatfactory.cpp \ | 138 | formatfactory.cpp \ |
140 | geo.cpp \ | 139 | geo.cpp \ |
141 | key.cpp \ | 140 | key.cpp \ |
142 | phonenumber.cpp \ | 141 | phonenumber.cpp \ |
143 | picture.cpp \ | 142 | picture.cpp \ |
144 | plugin.cpp \ | 143 | plugin.cpp \ |
145 | resource.cpp \ | 144 | resource.cpp \ |
146 | secrecy.cpp \ | 145 | secrecy.cpp \ |
147 | sound.cpp \ | 146 | sound.cpp \ |
148 | stdaddressbook.cpp \ | 147 | stdaddressbook.cpp \ |
149 | syncprefwidget.cpp \ | ||
150 | timezone.cpp \ | 148 | timezone.cpp \ |
151 | tmpaddressbook.cpp \ | 149 | tmpaddressbook.cpp \ |
152 | vcardconverter.cpp \ | 150 | vcardconverter.cpp \ |
153 | vcard21parser.cpp \ | 151 | vcard21parser.cpp \ |
154 | vcardformatimpl.cpp \ | 152 | vcardformatimpl.cpp \ |
155 | vcardformatplugin.cpp \ | 153 | vcardformatplugin.cpp \ |
156 | vcardparser/vcardline.cpp \ | 154 | vcardparser/vcardline.cpp \ |
157 | vcardparser/vcard.cpp \ | 155 | vcardparser/vcard.cpp \ |
158 | vcardparser/vcardtool.cpp \ | 156 | vcardparser/vcardtool.cpp \ |
159 | vcardparser/vcardparser.cpp \ | 157 | vcardparser/vcardparser.cpp \ |
160 | vcard/AdrParam.cpp \ | 158 | vcard/AdrParam.cpp \ |
161 | vcard/AdrValue.cpp \ | 159 | vcard/AdrValue.cpp \ |
162 | vcard/AgentParam.cpp \ | 160 | vcard/AgentParam.cpp \ |
163 | vcard/ContentLine.cpp \ | 161 | vcard/ContentLine.cpp \ |
164 | vcard/DateParam.cpp \ | 162 | vcard/DateParam.cpp \ |
165 | vcard/DateValue.cpp \ | 163 | vcard/DateValue.cpp \ |
166 | vcard/EmailParam.cpp \ | 164 | vcard/EmailParam.cpp \ |
167 | vcard/Entity.cpp \ | 165 | vcard/Entity.cpp \ |
168 | vcard/Enum.cpp \ | 166 | vcard/Enum.cpp \ |
169 | vcard/GeoValue.cpp \ | 167 | vcard/GeoValue.cpp \ |
170 | vcard/ImageParam.cpp \ | 168 | vcard/ImageParam.cpp \ |
171 | vcard/ImageValue.cpp \ | 169 | vcard/ImageValue.cpp \ |
172 | vcard/LangValue.cpp \ | 170 | vcard/LangValue.cpp \ |
173 | vcard/NValue.cpp \ | 171 | vcard/NValue.cpp \ |
174 | vcard/Param.cpp \ | 172 | vcard/Param.cpp \ |
175 | vcard/PhoneNumberValue.cpp \ | 173 | vcard/PhoneNumberValue.cpp \ |
176 | vcard/RToken.cpp \ | 174 | vcard/RToken.cpp \ |
177 | vcard/SourceParam.cpp \ | 175 | vcard/SourceParam.cpp \ |
178 | vcard/TelParam.cpp \ | 176 | vcard/TelParam.cpp \ |
179 | vcard/TextParam.cpp \ | 177 | vcard/TextParam.cpp \ |
180 | vcard/TextValue.cpp \ | 178 | vcard/TextValue.cpp \ |
181 | vcard/TextBinParam.cpp \ | 179 | vcard/TextBinParam.cpp \ |
182 | vcard/URIValue.cpp \ | 180 | vcard/URIValue.cpp \ |
183 | vcard/VCardv.cpp \ | 181 | vcard/VCardv.cpp \ |
184 | vcard/VCardEntity.cpp \ | 182 | vcard/VCardEntity.cpp \ |
185 | vcard/Value.cpp \ | 183 | vcard/Value.cpp \ |
186 | vcard/SoundValue.cpp \ | 184 | vcard/SoundValue.cpp \ |
187 | vcard/AgentValue.cpp \ | 185 | vcard/AgentValue.cpp \ |
188 | vcard/TelValue.cpp \ | 186 | vcard/TelValue.cpp \ |
189 | vcard/TextBinValue.cpp \ | 187 | vcard/TextBinValue.cpp \ |
190 | vcard/OrgValue.cpp \ | 188 | vcard/OrgValue.cpp \ |
191 | vcard/UTCValue.cpp \ | 189 | vcard/UTCValue.cpp \ |
192 | vcard/ClassValue.cpp \ | 190 | vcard/ClassValue.cpp \ |
193 | vcard/FloatValue.cpp \ | 191 | vcard/FloatValue.cpp \ |
194 | vcard/TextListValue.cpp | 192 | vcard/TextListValue.cpp |
195 | 193 | ||
196 | 194 | ||
197 | # plugins/ldap/resourceldap.cpp \ | 195 | # plugins/ldap/resourceldap.cpp \ |
198 | # plugins/ldap/resourceldapconfig.cpp \ | 196 | # plugins/ldap/resourceldapconfig.cpp \ |
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index e58e4f7..e2b7b08 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp | |||
@@ -1,212 +1,211 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include <sys/types.h> | 29 | #include <sys/types.h> |
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | #ifndef _WIN32_ | 31 | #ifndef _WIN32_ |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | //US #include <kgenericfactory.h> | 42 | //US #include <kgenericfactory.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | #include <klocale.h> | 44 | #include <klocale.h> |
45 | #include <kstandarddirs.h> | 45 | #include <kstandarddirs.h> |
46 | #include <kurlrequester.h> | 46 | #include <kurlrequester.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | 48 | ||
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | 50 | ||
51 | #include "formatfactory.h" | 51 | #include "formatfactory.h" |
52 | 52 | ||
53 | #include "resourcedirconfig.h" | 53 | #include "resourcedirconfig.h" |
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
55 | 55 | ||
56 | //US | 56 | //US |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | 58 | ||
59 | #define NO_DIRWATCH | 59 | #define NO_DIRWATCH |
60 | #include "resourcedir.h" | 60 | #include "resourcedir.h" |
61 | #include "syncprefwidget.h" | ||
62 | 61 | ||
63 | //#define ALLOW_LOCKING | 62 | //#define ALLOW_LOCKING |
64 | 63 | ||
65 | using namespace KABC; | 64 | using namespace KABC; |
66 | 65 | ||
67 | extern "C" | 66 | extern "C" |
68 | #ifdef _WIN32_ | 67 | #ifdef _WIN32_ |
69 | __declspec(dllexport) | 68 | __declspec(dllexport) |
70 | #else | 69 | #else |
71 | { | 70 | { |
72 | #endif | 71 | #endif |
73 | 72 | ||
74 | //US void *init_kabc_dir() | 73 | //US void *init_kabc_dir() |
75 | void *init_microkabc_dir() | 74 | void *init_microkabc_dir() |
76 | { | 75 | { |
77 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidgetContainer>(); | 76 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); |
78 | } | 77 | } |
79 | #ifndef _WIN32_ | 78 | #ifndef _WIN32_ |
80 | } | 79 | } |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | ResourceDir::ResourceDir( const KConfig *config, bool syncable ) | 82 | ResourceDir::ResourceDir( const KConfig *config ) |
84 | : Resource( config, syncable ) | 83 | : Resource( config ) |
85 | { | 84 | { |
86 | QString path; | 85 | QString path; |
87 | 86 | ||
88 | KConfig *cfg = (KConfig *)config; | 87 | KConfig *cfg = (KConfig *)config; |
89 | if ( cfg ) { | 88 | if ( cfg ) { |
90 | //US path = config->readEntry( "FilePath" ); | 89 | //US path = config->readEntry( "FilePath" ); |
91 | path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); | 90 | path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); |
92 | //US mFormatName = config->readEntry( "FileFormat" ); | 91 | //US mFormatName = config->readEntry( "FileFormat" ); |
93 | mFormatName = cfg->readEntry( "FileFormat", "vcard" ); | 92 | mFormatName = cfg->readEntry( "FileFormat", "vcard" ); |
94 | } else { | 93 | } else { |
95 | path = StdAddressBook::directoryName(); | 94 | path = StdAddressBook::directoryName(); |
96 | mFormatName = "vcard"; | 95 | mFormatName = "vcard"; |
97 | } | 96 | } |
98 | 97 | ||
99 | 98 | ||
100 | FormatFactory *factory = FormatFactory::self(); | 99 | FormatFactory *factory = FormatFactory::self(); |
101 | mFormat = factory->format( mFormatName ); | 100 | mFormat = factory->format( mFormatName ); |
102 | 101 | ||
103 | if ( !mFormat ) { | 102 | if ( !mFormat ) { |
104 | mFormatName = "vcard"; | 103 | mFormatName = "vcard"; |
105 | mFormat = factory->format( mFormatName ); | 104 | mFormat = factory->format( mFormatName ); |
106 | } | 105 | } |
107 | 106 | ||
108 | /*US | 107 | /*US |
109 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); | 108 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); |
110 | if (mFormatName == "vcard") | 109 | if (mFormatName == "vcard") |
111 | mFormat = new VCardFormatPlugin2(); | 110 | mFormat = new VCardFormatPlugin2(); |
112 | else if (mFormatName == "binary") | 111 | else if (mFormatName == "binary") |
113 | mFormat = new BinaryFormat(); | 112 | mFormat = new BinaryFormat(); |
114 | else | 113 | else |
115 | qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); | 114 | qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); |
116 | */ | 115 | */ |
117 | #ifndef NO_DIRWATCH | 116 | #ifndef NO_DIRWATCH |
118 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); | 117 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); |
119 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); | 118 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); |
120 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); | 119 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); |
121 | #endif | 120 | #endif |
122 | setPath( path ); | 121 | setPath( path ); |
123 | } | 122 | } |
124 | 123 | ||
125 | ResourceDir::~ResourceDir() | 124 | ResourceDir::~ResourceDir() |
126 | { | 125 | { |
127 | delete mFormat; | 126 | delete mFormat; |
128 | mFormat = 0; | 127 | mFormat = 0; |
129 | } | 128 | } |
130 | 129 | ||
131 | void ResourceDir::writeConfig( KConfig *config ) | 130 | void ResourceDir::writeConfig( KConfig *config ) |
132 | { | 131 | { |
133 | config->setGroup( "Resource_" + identifier() ); | 132 | config->setGroup( "Resource_" + identifier() ); |
134 | Resource::writeConfig( config ); | 133 | Resource::writeConfig( config ); |
135 | 134 | ||
136 | config->writeEntry( "FilePath", mPath ); | 135 | config->writeEntry( "FilePath", mPath ); |
137 | config->writeEntry( "FileFormat", mFormatName ); | 136 | config->writeEntry( "FileFormat", mFormatName ); |
138 | } | 137 | } |
139 | 138 | ||
140 | Ticket *ResourceDir::requestSaveTicket() | 139 | Ticket *ResourceDir::requestSaveTicket() |
141 | { | 140 | { |
142 | 141 | ||
143 | 142 | ||
144 | if ( !addressBook() ) return 0; | 143 | if ( !addressBook() ) return 0; |
145 | #ifdef ALLOW_LOCKING | 144 | #ifdef ALLOW_LOCKING |
146 | if ( !lock( mPath ) ) { | 145 | if ( !lock( mPath ) ) { |
147 | 146 | ||
148 | return 0; | 147 | return 0; |
149 | } | 148 | } |
150 | #endif | 149 | #endif |
151 | return createTicket( this ); | 150 | return createTicket( this ); |
152 | 151 | ||
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | bool ResourceDir::doOpen() | 155 | bool ResourceDir::doOpen() |
157 | { | 156 | { |
158 | QDir dir( mPath ); | 157 | QDir dir( mPath ); |
159 | if ( !dir.exists() ) { // no directory available | 158 | if ( !dir.exists() ) { // no directory available |
160 | return dir.mkdir( dir.path() ); | 159 | return dir.mkdir( dir.path() ); |
161 | } else { | 160 | } else { |
162 | QString testName = dir.entryList( QDir::Files )[0]; | 161 | QString testName = dir.entryList( QDir::Files )[0]; |
163 | if ( testName.isNull() || testName.isEmpty() ) // no file in directory | 162 | if ( testName.isNull() || testName.isEmpty() ) // no file in directory |
164 | return true; | 163 | return true; |
165 | 164 | ||
166 | QFile file( mPath + "/" + testName ); | 165 | QFile file( mPath + "/" + testName ); |
167 | if ( file.open( IO_ReadOnly ) ) | 166 | if ( file.open( IO_ReadOnly ) ) |
168 | return true; | 167 | return true; |
169 | 168 | ||
170 | if ( file.size() == 0 ) | 169 | if ( file.size() == 0 ) |
171 | return true; | 170 | return true; |
172 | 171 | ||
173 | bool ok = mFormat->checkFormat( &file ); | 172 | bool ok = mFormat->checkFormat( &file ); |
174 | file.close(); | 173 | file.close(); |
175 | return ok; | 174 | return ok; |
176 | } | 175 | } |
177 | } | 176 | } |
178 | 177 | ||
179 | void ResourceDir::doClose() | 178 | void ResourceDir::doClose() |
180 | { | 179 | { |
181 | } | 180 | } |
182 | 181 | ||
183 | bool ResourceDir::load() | 182 | bool ResourceDir::load() |
184 | { | 183 | { |
185 | QDir dir( mPath ); | 184 | QDir dir( mPath ); |
186 | QStringList files = dir.entryList( QDir::Files ); | 185 | QStringList files = dir.entryList( QDir::Files ); |
187 | 186 | ||
188 | QStringList::Iterator it; | 187 | QStringList::Iterator it; |
189 | bool ok = true; | 188 | bool ok = true; |
190 | for ( it = files.begin(); it != files.end(); ++it ) { | 189 | for ( it = files.begin(); it != files.end(); ++it ) { |
191 | QFile file( mPath + "/" + (*it) ); | 190 | QFile file( mPath + "/" + (*it) ); |
192 | 191 | ||
193 | if ( !file.open( IO_ReadOnly ) ) { | 192 | if ( !file.open( IO_ReadOnly ) ) { |
194 | addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) ); | 193 | addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) ); |
195 | ok = false; | 194 | ok = false; |
196 | continue; | 195 | continue; |
197 | } | 196 | } |
198 | 197 | ||
199 | if ( !mFormat->loadAll( addressBook(), this, &file ) ) | 198 | if ( !mFormat->loadAll( addressBook(), this, &file ) ) |
200 | ok = false; | 199 | ok = false; |
201 | 200 | ||
202 | file.close(); | 201 | file.close(); |
203 | } | 202 | } |
204 | 203 | ||
205 | return ok; | 204 | return ok; |
206 | } | 205 | } |
207 | 206 | ||
208 | bool ResourceDir::save( Ticket *ticket ) | 207 | bool ResourceDir::save( Ticket *ticket ) |
209 | { | 208 | { |
210 | AddressBook::Iterator it; | 209 | AddressBook::Iterator it; |
211 | bool ok = true; | 210 | bool ok = true; |
212 | #ifndef NO_DIRWATCH | 211 | #ifndef NO_DIRWATCH |
diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h index 77cd18c..6c1e922 100644 --- a/kabc/plugins/dir/resourcedir.h +++ b/kabc/plugins/dir/resourcedir.h | |||
@@ -1,116 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_RESOURCEDIR_H | 28 | #ifndef KABC_RESOURCEDIR_H |
29 | #define KABC_RESOURCEDIR_H | 29 | #define KABC_RESOURCEDIR_H |
30 | 30 | ||
31 | #include <kconfig.h> | 31 | #include <kconfig.h> |
32 | #include <kdirwatch.h> | 32 | #include <kdirwatch.h> |
33 | 33 | ||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | 35 | ||
36 | #include "resource.h" | 36 | #include "resource.h" |
37 | 37 | ||
38 | class QTimer; | 38 | class QTimer; |
39 | 39 | ||
40 | namespace KABC { | 40 | namespace KABC { |
41 | 41 | ||
42 | class FormatPlugin; | 42 | class FormatPlugin; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | @internal | 45 | @internal |
46 | */ | 46 | */ |
47 | class ResourceDir : public Resource | 47 | class ResourceDir : public Resource |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | 50 | ||
51 | public: | 51 | public: |
52 | ResourceDir( const KConfig*, bool syncable ); | 52 | ResourceDir( const KConfig* ); |
53 | ~ResourceDir(); | 53 | ~ResourceDir(); |
54 | 54 | ||
55 | virtual void writeConfig( KConfig* ); | 55 | virtual void writeConfig( KConfig* ); |
56 | 56 | ||
57 | virtual bool doOpen(); | 57 | virtual bool doOpen(); |
58 | virtual void doClose(); | 58 | virtual void doClose(); |
59 | 59 | ||
60 | virtual Ticket *requestSaveTicket(); | 60 | virtual Ticket *requestSaveTicket(); |
61 | 61 | ||
62 | virtual bool load(); | 62 | virtual bool load(); |
63 | virtual bool save( Ticket * ); | 63 | virtual bool save( Ticket * ); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Set path to be used for saving. | 66 | * Set path to be used for saving. |
67 | */ | 67 | */ |
68 | void setPath( const QString & ); | 68 | void setPath( const QString & ); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Return path used for loading and saving the address book. | 71 | * Return path used for loading and saving the address book. |
72 | */ | 72 | */ |
73 | QString path() const; | 73 | QString path() const; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Set the format by name. | 76 | * Set the format by name. |
77 | */ | 77 | */ |
78 | void setFormat( const QString &format ); | 78 | void setFormat( const QString &format ); |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Returns the format name. | 81 | * Returns the format name. |
82 | */ | 82 | */ |
83 | QString format() const; | 83 | QString format() const; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Remove a addressee from its source. | 86 | * Remove a addressee from its source. |
87 | * This method is mainly called by KABC::AddressBook. | 87 | * This method is mainly called by KABC::AddressBook. |
88 | */ | 88 | */ |
89 | virtual void removeAddressee( const Addressee& addr ); | 89 | virtual void removeAddressee( const Addressee& addr ); |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * This method is called by an error handler if the application | 92 | * This method is called by an error handler if the application |
93 | * crashed | 93 | * crashed |
94 | */ | 94 | */ |
95 | virtual void cleanUp(); | 95 | virtual void cleanUp(); |
96 | 96 | ||
97 | protected slots: | 97 | protected slots: |
98 | void pathChanged(); | 98 | void pathChanged(); |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | bool lock( const QString &path ); | 101 | bool lock( const QString &path ); |
102 | void unlock( const QString &path ); | 102 | void unlock( const QString &path ); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | FormatPlugin *mFormat; | 105 | FormatPlugin *mFormat; |
106 | 106 | ||
107 | #ifndef NO_DIRWATCH | 107 | #ifndef NO_DIRWATCH |
108 | KDirWatch mDirWatch; | 108 | KDirWatch mDirWatch; |
109 | #endif | 109 | #endif |
110 | QString mPath; | 110 | QString mPath; |
111 | QString mFormatName; | 111 | QString mFormatName; |
112 | QString mLockUniqueName; | 112 | QString mLockUniqueName; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | } | 115 | } |
116 | #endif | 116 | #endif |
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 163f2b4..dc5932f 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -1,230 +1,226 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #ifndef _WIN32_ | 30 | #ifndef _WIN32_ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
46 | 46 | ||
47 | #include "formatfactory.h" | 47 | #include "formatfactory.h" |
48 | 48 | ||
49 | #include "resource.h" | 49 | #include "resource.h" |
50 | #include "resourcefileconfig.h" | 50 | #include "resourcefileconfig.h" |
51 | #include "stdaddressbook.h" | 51 | #include "stdaddressbook.h" |
52 | #define NO_DIRWATCH | 52 | #define NO_DIRWATCH |
53 | #include "resourcefile.h" | 53 | #include "resourcefile.h" |
54 | #include "syncprefwidget.h" | ||
55 | 54 | ||
56 | //#define ALLOW_LOCKING | 55 | //#define ALLOW_LOCKING |
57 | 56 | ||
58 | 57 | ||
59 | 58 | ||
60 | using namespace KABC; | 59 | using namespace KABC; |
61 | 60 | ||
62 | extern "C" | 61 | extern "C" |
63 | #ifdef _WIN32_ | 62 | #ifdef _WIN32_ |
64 | __declspec(dllexport) | 63 | __declspec(dllexport) |
65 | #else | 64 | #else |
66 | { | 65 | { |
67 | #endif | 66 | #endif |
68 | 67 | ||
69 | //US void *init_kabc_file() | 68 | //US void *init_kabc_file() |
70 | void *init_microkabc_file() | 69 | void *init_microkabc_file() |
71 | { | 70 | { |
72 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); | 71 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); |
73 | } | 72 | } |
74 | #ifndef _WIN32_ | 73 | #ifndef _WIN32_ |
75 | } | 74 | } |
76 | #endif | 75 | #endif |
77 | 76 | ||
78 | ResourceFile::ResourceFile( const KConfig *config, bool syncable ) | 77 | ResourceFile::ResourceFile( const KConfig *config ) |
79 | : Resource( config, syncable ) , mFormat( 0 ) | 78 | : Resource( config ) , mFormat( 0 ) |
80 | { | 79 | { |
81 | QString fileName, formatName, default_fileName; | 80 | QString fileName, formatName, default_fileName; |
82 | 81 | ||
83 | if (syncable == true) | 82 | default_fileName = StdAddressBook::fileName(); |
84 | default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf"; | ||
85 | else | ||
86 | default_fileName = StdAddressBook::fileName(); | ||
87 | 83 | ||
88 | KConfig *cfg = (KConfig *)config; | 84 | KConfig *cfg = (KConfig *)config; |
89 | if ( cfg ) { | 85 | if ( cfg ) { |
90 | fileName = cfg->readEntry( "FileName", default_fileName ); | 86 | fileName = cfg->readEntry( "FileName", default_fileName ); |
91 | formatName = cfg->readEntry( "FileFormat", "vcard" ); | 87 | formatName = cfg->readEntry( "FileFormat", "vcard" ); |
92 | } else { | 88 | } else { |
93 | fileName = default_fileName; | 89 | fileName = default_fileName; |
94 | formatName = "vcard"; | 90 | formatName = "vcard"; |
95 | } | 91 | } |
96 | 92 | ||
97 | init( fileName, formatName ); | 93 | init( fileName, formatName ); |
98 | } | 94 | } |
99 | 95 | ||
100 | ResourceFile::ResourceFile( const QString &fileName, bool syncable , | 96 | ResourceFile::ResourceFile( const QString &fileName , |
101 | const QString &formatName ) | 97 | const QString &formatName ) |
102 | : Resource( 0, syncable ) | 98 | : Resource( 0 ) |
103 | { | 99 | { |
104 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 100 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
105 | init( fileName, formatName ); | 101 | init( fileName, formatName ); |
106 | } | 102 | } |
107 | 103 | ||
108 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 104 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
109 | { | 105 | { |
110 | mFormatName = formatName; | 106 | mFormatName = formatName; |
111 | 107 | ||
112 | FormatFactory *factory = FormatFactory::self(); | 108 | FormatFactory *factory = FormatFactory::self(); |
113 | mFormat = factory->format( mFormatName ); | 109 | mFormat = factory->format( mFormatName ); |
114 | 110 | ||
115 | if ( !mFormat ) { | 111 | if ( !mFormat ) { |
116 | mFormatName = "vcard"; | 112 | mFormatName = "vcard"; |
117 | mFormat = factory->format( mFormatName ); | 113 | mFormat = factory->format( mFormatName ); |
118 | } | 114 | } |
119 | 115 | ||
120 | #ifndef NO_DIRWATCH | 116 | #ifndef NO_DIRWATCH |
121 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 117 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
122 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 118 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
123 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 119 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
124 | #endif | 120 | #endif |
125 | setFileName( fileName ); | 121 | setFileName( fileName ); |
126 | } | 122 | } |
127 | 123 | ||
128 | ResourceFile::~ResourceFile() | 124 | ResourceFile::~ResourceFile() |
129 | { | 125 | { |
130 | delete mFormat; | 126 | delete mFormat; |
131 | mFormat = 0; | 127 | mFormat = 0; |
132 | } | 128 | } |
133 | 129 | ||
134 | void ResourceFile::writeConfig( KConfig *config ) | 130 | void ResourceFile::writeConfig( KConfig *config ) |
135 | { | 131 | { |
136 | 132 | ||
137 | config->setGroup( "Resource_" + identifier() ); | 133 | config->setGroup( "Resource_" + identifier() ); |
138 | Resource::writeConfig( config ); | 134 | Resource::writeConfig( config ); |
139 | 135 | ||
140 | config->writeEntry( "FileName", mFileName ); | 136 | config->writeEntry( "FileName", mFileName ); |
141 | config->writeEntry( "FileFormat", mFormatName ); | 137 | config->writeEntry( "FileFormat", mFormatName ); |
142 | 138 | ||
143 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 139 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
144 | 140 | ||
145 | } | 141 | } |
146 | 142 | ||
147 | Ticket *ResourceFile::requestSaveTicket() | 143 | Ticket *ResourceFile::requestSaveTicket() |
148 | { | 144 | { |
149 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; | 145 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; |
150 | 146 | ||
151 | if ( !addressBook() ) return 0; | 147 | if ( !addressBook() ) return 0; |
152 | 148 | ||
153 | #ifdef ALLOW_LOCKING | 149 | #ifdef ALLOW_LOCKING |
154 | if ( !lock( mFileName ) ) { | 150 | if ( !lock( mFileName ) ) { |
155 | qDebug("unablt to lock file "); | 151 | qDebug("unablt to lock file "); |
156 | return 0; | 152 | return 0; |
157 | } | 153 | } |
158 | #endif | 154 | #endif |
159 | return createTicket( this ); | 155 | return createTicket( this ); |
160 | } | 156 | } |
161 | 157 | ||
162 | 158 | ||
163 | bool ResourceFile::doOpen() | 159 | bool ResourceFile::doOpen() |
164 | { | 160 | { |
165 | QFile file( mFileName ); | 161 | QFile file( mFileName ); |
166 | qDebug("ResourceFile::openfile %s ", mFileName.latin1()); | 162 | qDebug("ResourceFile::openfile %s ", mFileName.latin1()); |
167 | 163 | ||
168 | if ( !file.exists() ) { | 164 | if ( !file.exists() ) { |
169 | // try to create the file | 165 | // try to create the file |
170 | bool ok = file.open( IO_WriteOnly ); | 166 | bool ok = file.open( IO_WriteOnly ); |
171 | if ( ok ) | 167 | if ( ok ) |
172 | file.close(); | 168 | file.close(); |
173 | 169 | ||
174 | return ok; | 170 | return ok; |
175 | } else { | 171 | } else { |
176 | if ( !file.open( IO_ReadWrite ) ) | 172 | if ( !file.open( IO_ReadWrite ) ) |
177 | return false; | 173 | return false; |
178 | 174 | ||
179 | if ( file.size() == 0 ) { | 175 | if ( file.size() == 0 ) { |
180 | file.close(); | 176 | file.close(); |
181 | return true; | 177 | return true; |
182 | } | 178 | } |
183 | 179 | ||
184 | bool ok = mFormat->checkFormat( &file ); | 180 | bool ok = mFormat->checkFormat( &file ); |
185 | file.close(); | 181 | file.close(); |
186 | 182 | ||
187 | return ok; | 183 | return ok; |
188 | } | 184 | } |
189 | } | 185 | } |
190 | 186 | ||
191 | void ResourceFile::doClose() | 187 | void ResourceFile::doClose() |
192 | { | 188 | { |
193 | } | 189 | } |
194 | 190 | ||
195 | bool ResourceFile::load() | 191 | bool ResourceFile::load() |
196 | { | 192 | { |
197 | 193 | ||
198 | QFile file( mFileName ); | 194 | QFile file( mFileName ); |
199 | if ( !file.open( IO_ReadOnly ) ) { | 195 | if ( !file.open( IO_ReadOnly ) ) { |
200 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); | 196 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); |
201 | return false; | 197 | return false; |
202 | } | 198 | } |
203 | 199 | ||
204 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 200 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
205 | 201 | ||
206 | return mFormat->loadAll( addressBook(), this, &file ); | 202 | return mFormat->loadAll( addressBook(), this, &file ); |
207 | } | 203 | } |
208 | 204 | ||
209 | bool ResourceFile::save( Ticket *ticket ) | 205 | bool ResourceFile::save( Ticket *ticket ) |
210 | { | 206 | { |
211 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 207 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
212 | 208 | ||
213 | 209 | ||
214 | // create backup file | 210 | // create backup file |
215 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | 211 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); |
216 | 212 | ||
217 | /*US we use a simpler method to create a backupfile | 213 | /*US we use a simpler method to create a backupfile |
218 | 214 | ||
219 | (void) KSaveFile::backupFile( mFileName, QString::null | 215 | (void) KSaveFile::backupFile( mFileName, QString::null |
220 | ,extension ); | 216 | ,extension ); |
221 | 217 | ||
222 | KSaveFile saveFile( mFileName ); | 218 | KSaveFile saveFile( mFileName ); |
223 | bool ok = false; | 219 | bool ok = false; |
224 | if ( saveFile.status() == 0 && saveFile.file() ) | 220 | if ( saveFile.status() == 0 && saveFile.file() ) |
225 | { | 221 | { |
226 | mFormat->saveAll( addressBook(), this, saveFile.file() ); | 222 | mFormat->saveAll( addressBook(), this, saveFile.file() ); |
227 | ok = saveFile.close(); | 223 | ok = saveFile.close(); |
228 | } | 224 | } |
229 | */ | 225 | */ |
230 | 226 | ||
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h index 8339340..b4421b2 100644 --- a/kabc/plugins/file/resourcefile.h +++ b/kabc/plugins/file/resourcefile.h | |||
@@ -1,163 +1,163 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #ifndef KABC_RESOURCEFILE_H | 29 | #ifndef KABC_RESOURCEFILE_H |
30 | #define KABC_RESOURCEFILE_H | 30 | #define KABC_RESOURCEFILE_H |
31 | 31 | ||
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdirwatch.h> | 33 | #include <kdirwatch.h> |
34 | 34 | ||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | 36 | ||
37 | #include <resource.h> | 37 | #include <resource.h> |
38 | 38 | ||
39 | class QTimer; | 39 | class QTimer; |
40 | class FormatPlugin; | 40 | class FormatPlugin; |
41 | 41 | ||
42 | namespace KABC { | 42 | namespace KABC { |
43 | 43 | ||
44 | //US class FormatPlugin; | 44 | //US class FormatPlugin; |
45 | class ResourceConfigWidget; | 45 | class ResourceConfigWidget; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | @internal | 48 | @internal |
49 | */ | 49 | */ |
50 | class ResourceFile : public Resource | 50 | class ResourceFile : public Resource |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | 55 | ||
56 | /** | 56 | /** |
57 | Constructor. | 57 | Constructor. |
58 | 58 | ||
59 | @param cfg The config object where custom resource settings are stored. | 59 | @param cfg The config object where custom resource settings are stored. |
60 | */ | 60 | */ |
61 | ResourceFile( const KConfig *cfg, bool syncable ); | 61 | ResourceFile( const KConfig *cfg ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | Construct file resource on file @arg fileName using format @arg formatName. | 64 | Construct file resource on file @arg fileName using format @arg formatName. |
65 | */ | 65 | */ |
66 | ResourceFile( const QString &fileName, bool syncable , const QString &formatName = "vcard" ); | 66 | ResourceFile( const QString &fileName , const QString &formatName = "vcard" ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Destructor. | 69 | * Destructor. |
70 | */ | 70 | */ |
71 | ~ResourceFile(); | 71 | ~ResourceFile(); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Writes the config back. | 74 | Writes the config back. |
75 | */ | 75 | */ |
76 | virtual void writeConfig( KConfig *cfg ); | 76 | virtual void writeConfig( KConfig *cfg ); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Tries to open the file and checks for the proper format. | 79 | * Tries to open the file and checks for the proper format. |
80 | * This method should be called before @ref load(). | 80 | * This method should be called before @ref load(). |
81 | */ | 81 | */ |
82 | virtual bool doOpen(); | 82 | virtual bool doOpen(); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Closes the file again. | 85 | * Closes the file again. |
86 | */ | 86 | */ |
87 | virtual void doClose(); | 87 | virtual void doClose(); |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Requests a save ticket, that is used by @ref save() | 90 | * Requests a save ticket, that is used by @ref save() |
91 | */ | 91 | */ |
92 | virtual Ticket *requestSaveTicket(); | 92 | virtual Ticket *requestSaveTicket(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Loads all addressees from file to the address book. | 95 | * Loads all addressees from file to the address book. |
96 | * Returns true if all addressees could be loaded otherwise false. | 96 | * Returns true if all addressees could be loaded otherwise false. |
97 | */ | 97 | */ |
98 | virtual bool load(); | 98 | virtual bool load(); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Saves all addresses from address book to file. | 101 | * Saves all addresses from address book to file. |
102 | * Returns true if all addressees could be saved otherwise false. | 102 | * Returns true if all addressees could be saved otherwise false. |
103 | * | 103 | * |
104 | * @param ticket The ticket returned by @ref requestSaveTicket() | 104 | * @param ticket The ticket returned by @ref requestSaveTicket() |
105 | */ | 105 | */ |
106 | virtual bool save( Ticket *ticket ); | 106 | virtual bool save( Ticket *ticket ); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Set name of file to be used for saving. | 109 | * Set name of file to be used for saving. |
110 | */ | 110 | */ |
111 | void setFileName( const QString & ); | 111 | void setFileName( const QString & ); |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * Return name of file used for loading and saving the address book. | 114 | * Return name of file used for loading and saving the address book. |
115 | */ | 115 | */ |
116 | QString fileName() const; | 116 | QString fileName() const; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | Sets a new format by name. | 119 | Sets a new format by name. |
120 | */ | 120 | */ |
121 | void setFormat( const QString &name ); | 121 | void setFormat( const QString &name ); |
122 | 122 | ||
123 | /** | 123 | /** |
124 | Returns the format name. | 124 | Returns the format name. |
125 | */ | 125 | */ |
126 | QString format() const; | 126 | QString format() const; |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Remove a addressee from its source. | 129 | * Remove a addressee from its source. |
130 | * This method is mainly called by KABC::AddressBook. | 130 | * This method is mainly called by KABC::AddressBook. |
131 | */ | 131 | */ |
132 | virtual void removeAddressee( const Addressee& addr ); | 132 | virtual void removeAddressee( const Addressee& addr ); |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * This method is called by an error handler if the application | 135 | * This method is called by an error handler if the application |
136 | * crashed | 136 | * crashed |
137 | */ | 137 | */ |
138 | virtual void cleanUp(); | 138 | virtual void cleanUp(); |
139 | 139 | ||
140 | protected slots: | 140 | protected slots: |
141 | void fileChanged(); | 141 | void fileChanged(); |
142 | 142 | ||
143 | protected: | 143 | protected: |
144 | void init( const QString &fileName, const QString &format ); | 144 | void init( const QString &fileName, const QString &format ); |
145 | 145 | ||
146 | bool lock( const QString &fileName ); | 146 | bool lock( const QString &fileName ); |
147 | void unlock( const QString &fileName ); | 147 | void unlock( const QString &fileName ); |
148 | 148 | ||
149 | private: | 149 | private: |
150 | QString mFileName; | 150 | QString mFileName; |
151 | QString mFormatName; | 151 | QString mFormatName; |
152 | 152 | ||
153 | FormatPlugin *mFormat; | 153 | FormatPlugin *mFormat; |
154 | 154 | ||
155 | QString mLockUniqueName; | 155 | QString mLockUniqueName; |
156 | #ifndef NO_DIRWATCH | 156 | #ifndef NO_DIRWATCH |
157 | KDirWatch mDirWatch; | 157 | KDirWatch mDirWatch; |
158 | #endif | 158 | #endif |
159 | }; | 159 | }; |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | #endif | 163 | #endif |
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp index 17f115d..55c43af 100644 --- a/kabc/plugins/ldap/resourceldap.cpp +++ b/kabc/plugins/ldap/resourceldap.cpp | |||
@@ -1,184 +1,183 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klineedit.h> | 30 | #include <klineedit.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kstringhandler.h> | 33 | #include <kstringhandler.h> |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | #include "resourceldap.h" | 37 | #include "resourceldap.h" |
38 | #include "resourceldapconfig.h" | 38 | #include "resourceldapconfig.h" |
39 | #include "syncprefwidget.h" | ||
40 | 39 | ||
41 | using namespace KABC; | 40 | using namespace KABC; |
42 | 41 | ||
43 | extern "C" | 42 | extern "C" |
44 | { | 43 | { |
45 | //US void *init_kabc_ldap() | 44 | //US void *init_kabc_ldap() |
46 | void *init_microkabc_ldap() | 45 | void *init_microkabc_ldap() |
47 | { | 46 | { |
48 | return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidgetContainer>(); | 47 | return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>(); |
49 | } | 48 | } |
50 | } | 49 | } |
51 | 50 | ||
52 | void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); | 51 | void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); |
53 | 52 | ||
54 | 53 | ||
55 | ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable ) | 54 | ResourceLDAP::ResourceLDAP( const KConfig *config ) |
56 | : Resource( config, syncable ), mPort( 389 ), mLdap( 0 ) | 55 | : Resource( config ), mPort( 389 ), mLdap( 0 ) |
57 | { | 56 | { |
58 | KConfig *cfg = (KConfig *)config; | 57 | KConfig *cfg = (KConfig *)config; |
59 | if ( cfg ) { | 58 | if ( cfg ) { |
60 | mUser = cfg->readEntry( "LdapUser" ); | 59 | mUser = cfg->readEntry( "LdapUser" ); |
61 | mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) ); | 60 | mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) ); |
62 | mDn = cfg->readEntry( "LdapDn" ); | 61 | mDn = cfg->readEntry( "LdapDn" ); |
63 | mHost = cfg->readEntry( "LdapHost" ); | 62 | mHost = cfg->readEntry( "LdapHost" ); |
64 | mPort = cfg->readNumEntry( "LdapPort", 389 ); | 63 | mPort = cfg->readNumEntry( "LdapPort", 389 ); |
65 | mFilter = cfg->readEntry( "LdapFilter" ); | 64 | mFilter = cfg->readEntry( "LdapFilter" ); |
66 | mAnonymous = cfg->readBoolEntry( "LdapAnonymous" ); | 65 | mAnonymous = cfg->readBoolEntry( "LdapAnonymous" ); |
67 | 66 | ||
68 | QStringList attributes = cfg->readListEntry( "LdapAttributes" ); | 67 | QStringList attributes = cfg->readListEntry( "LdapAttributes" ); |
69 | for ( uint pos = 0; pos < attributes.count(); pos += 2 ) | 68 | for ( uint pos = 0; pos < attributes.count(); pos += 2 ) |
70 | mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] ); | 69 | mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] ); |
71 | } | 70 | } |
72 | 71 | ||
73 | /** | 72 | /** |
74 | If you want to add new attributes, append them here, add a | 73 | If you want to add new attributes, append them here, add a |
75 | translation string in the ctor of AttributesDialog and | 74 | translation string in the ctor of AttributesDialog and |
76 | handle them in the load() method below. | 75 | handle them in the load() method below. |
77 | These are the default values from | 76 | These are the default values from |
78 | */ | 77 | */ |
79 | if ( mAttributes.count() == 0 ) { | 78 | if ( mAttributes.count() == 0 ) { |
80 | mAttributes.insert( "commonName", "cn" ); | 79 | mAttributes.insert( "commonName", "cn" ); |
81 | mAttributes.insert( "formattedName", "displayName" ); | 80 | mAttributes.insert( "formattedName", "displayName" ); |
82 | mAttributes.insert( "familyName", "sn" ); | 81 | mAttributes.insert( "familyName", "sn" ); |
83 | mAttributes.insert( "givenName", "givenName" ); | 82 | mAttributes.insert( "givenName", "givenName" ); |
84 | mAttributes.insert( "mail", "mail" ); | 83 | mAttributes.insert( "mail", "mail" ); |
85 | mAttributes.insert( "mailAlias", "" ); | 84 | mAttributes.insert( "mailAlias", "" ); |
86 | mAttributes.insert( "phoneNumber", "telephoneNumber" ); | 85 | mAttributes.insert( "phoneNumber", "telephoneNumber" ); |
87 | mAttributes.insert( "uid", "uid" ); | 86 | mAttributes.insert( "uid", "uid" ); |
88 | } | 87 | } |
89 | } | 88 | } |
90 | 89 | ||
91 | void ResourceLDAP::writeConfig( KConfig *config ) | 90 | void ResourceLDAP::writeConfig( KConfig *config ) |
92 | { | 91 | { |
93 | Resource::writeConfig( config ); | 92 | Resource::writeConfig( config ); |
94 | 93 | ||
95 | config->writeEntry( "LdapUser", mUser ); | 94 | config->writeEntry( "LdapUser", mUser ); |
96 | config->writeEntry( "LdapPassword", KStringHandler::obscure( mPassword ) ); | 95 | config->writeEntry( "LdapPassword", KStringHandler::obscure( mPassword ) ); |
97 | config->writeEntry( "LdapDn", mDn ); | 96 | config->writeEntry( "LdapDn", mDn ); |
98 | config->writeEntry( "LdapHost", mHost ); | 97 | config->writeEntry( "LdapHost", mHost ); |
99 | config->writeEntry( "LdapPort", mPort ); | 98 | config->writeEntry( "LdapPort", mPort ); |
100 | config->writeEntry( "LdapFilter", mFilter ); | 99 | config->writeEntry( "LdapFilter", mFilter ); |
101 | config->writeEntry( "LdapAnonymous", mAnonymous ); | 100 | config->writeEntry( "LdapAnonymous", mAnonymous ); |
102 | 101 | ||
103 | QStringList attributes; | 102 | QStringList attributes; |
104 | QMap<QString, QString>::Iterator it; | 103 | QMap<QString, QString>::Iterator it; |
105 | for ( it = mAttributes.begin(); it != mAttributes.end(); ++it ) | 104 | for ( it = mAttributes.begin(); it != mAttributes.end(); ++it ) |
106 | attributes << it.key() << it.data(); | 105 | attributes << it.key() << it.data(); |
107 | 106 | ||
108 | config->writeEntry( "LdapAttributes", attributes ); | 107 | config->writeEntry( "LdapAttributes", attributes ); |
109 | } | 108 | } |
110 | 109 | ||
111 | Ticket *ResourceLDAP::requestSaveTicket() | 110 | Ticket *ResourceLDAP::requestSaveTicket() |
112 | { | 111 | { |
113 | if ( !addressBook() ) { | 112 | if ( !addressBook() ) { |
114 | kdDebug(5700) << "no addressbook" << endl; | 113 | kdDebug(5700) << "no addressbook" << endl; |
115 | return 0; | 114 | return 0; |
116 | } | 115 | } |
117 | 116 | ||
118 | return createTicket( this ); | 117 | return createTicket( this ); |
119 | } | 118 | } |
120 | 119 | ||
121 | bool ResourceLDAP::doOpen() | 120 | bool ResourceLDAP::doOpen() |
122 | { | 121 | { |
123 | if ( mLdap ) | 122 | if ( mLdap ) |
124 | return false; | 123 | return false; |
125 | 124 | ||
126 | if ( !mPort ) | 125 | if ( !mPort ) |
127 | mPort = 389; | 126 | mPort = 389; |
128 | 127 | ||
129 | mLdap = ldap_init( mHost.local8Bit(), mPort ); | 128 | mLdap = ldap_init( mHost.local8Bit(), mPort ); |
130 | if ( !mLdap ) { | 129 | if ( !mLdap ) { |
131 | addressBook()->error( i18n( "Unable to connect to server '%1' on port '%2'" ).arg( mHost ).arg( mPort ) ); | 130 | addressBook()->error( i18n( "Unable to connect to server '%1' on port '%2'" ).arg( mHost ).arg( mPort ) ); |
132 | return false; | 131 | return false; |
133 | } | 132 | } |
134 | 133 | ||
135 | if ( !mUser.isEmpty() && !mAnonymous ) { | 134 | if ( !mUser.isEmpty() && !mAnonymous ) { |
136 | if ( ldap_simple_bind_s( mLdap, mUser.local8Bit(), mPassword.local8Bit() ) != LDAP_SUCCESS ) { | 135 | if ( ldap_simple_bind_s( mLdap, mUser.local8Bit(), mPassword.local8Bit() ) != LDAP_SUCCESS ) { |
137 | addressBook()->error( i18n( "Unable to bind to server '%1'" ).arg( mHost ) ); | 136 | addressBook()->error( i18n( "Unable to bind to server '%1'" ).arg( mHost ) ); |
138 | return false; | 137 | return false; |
139 | } | 138 | } |
140 | 139 | ||
141 | kdDebug(5700) << "ResourceLDAP: bind to server successfully" << endl; | 140 | kdDebug(5700) << "ResourceLDAP: bind to server successfully" << endl; |
142 | } else { | 141 | } else { |
143 | if ( ldap_simple_bind_s( mLdap, NULL, NULL ) != LDAP_SUCCESS ) { | 142 | if ( ldap_simple_bind_s( mLdap, NULL, NULL ) != LDAP_SUCCESS ) { |
144 | addressBook()->error( i18n( "Unable to bind anonymously to server '%1'" ).arg( mHost ) ); | 143 | addressBook()->error( i18n( "Unable to bind anonymously to server '%1'" ).arg( mHost ) ); |
145 | return false; | 144 | return false; |
146 | } | 145 | } |
147 | 146 | ||
148 | kdDebug( 5700 ) << "ResourceLDAP: bind anonymously to server successfully" << endl; | 147 | kdDebug( 5700 ) << "ResourceLDAP: bind anonymously to server successfully" << endl; |
149 | } | 148 | } |
150 | 149 | ||
151 | int deref = LDAP_DEREF_ALWAYS; | 150 | int deref = LDAP_DEREF_ALWAYS; |
152 | if ( ldap_set_option( mLdap, LDAP_OPT_DEREF, (void *) &deref ) != LDAP_OPT_SUCCESS ) { | 151 | if ( ldap_set_option( mLdap, LDAP_OPT_DEREF, (void *) &deref ) != LDAP_OPT_SUCCESS ) { |
153 | kdDebug(5700) << "ResourceLDAP: can't set 'deref' option" << endl; | 152 | kdDebug(5700) << "ResourceLDAP: can't set 'deref' option" << endl; |
154 | return false; | 153 | return false; |
155 | } | 154 | } |
156 | 155 | ||
157 | if ( ldap_set_option( mLdap, LDAP_OPT_REFERRALS, LDAP_OPT_ON ) != LDAP_OPT_SUCCESS ) { | 156 | if ( ldap_set_option( mLdap, LDAP_OPT_REFERRALS, LDAP_OPT_ON ) != LDAP_OPT_SUCCESS ) { |
158 | kdDebug(5700) << "ResourceLDAP: can't set 'referrals' option" << endl; | 157 | kdDebug(5700) << "ResourceLDAP: can't set 'referrals' option" << endl; |
159 | return false; | 158 | return false; |
160 | } | 159 | } |
161 | 160 | ||
162 | return true; | 161 | return true; |
163 | } | 162 | } |
164 | 163 | ||
165 | void ResourceLDAP::doClose() | 164 | void ResourceLDAP::doClose() |
166 | { | 165 | { |
167 | if ( ldap_unbind_s( mLdap ) != LDAP_SUCCESS ) { | 166 | if ( ldap_unbind_s( mLdap ) != LDAP_SUCCESS ) { |
168 | kdDebug(5700) << "ResourceLDAP: can't unbind from server" << endl; | 167 | kdDebug(5700) << "ResourceLDAP: can't unbind from server" << endl; |
169 | return; | 168 | return; |
170 | } | 169 | } |
171 | 170 | ||
172 | mLdap = 0; | 171 | mLdap = 0; |
173 | } | 172 | } |
174 | 173 | ||
175 | bool ResourceLDAP::load() | 174 | bool ResourceLDAP::load() |
176 | { | 175 | { |
177 | LDAPMessage *res; | 176 | LDAPMessage *res; |
178 | LDAPMessage *msg; | 177 | LDAPMessage *msg; |
179 | BerElement *track; | 178 | BerElement *track; |
180 | char *names; | 179 | char *names; |
181 | char **values; | 180 | char **values; |
182 | 181 | ||
183 | char **LdapSearchAttr = new char*[ mAttributes.count() + 1 ]; | 182 | char **LdapSearchAttr = new char*[ mAttributes.count() + 1 ]; |
184 | 183 | ||
diff --git a/kabc/plugins/ldap/resourceldap.h b/kabc/plugins/ldap/resourceldap.h index 0aad3c1..0625f30 100644 --- a/kabc/plugins/ldap/resourceldap.h +++ b/kabc/plugins/ldap/resourceldap.h | |||
@@ -1,99 +1,99 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_RESOURCELDAP_H | 28 | #ifndef KABC_RESOURCELDAP_H |
29 | #define KABC_RESOURCELDAP_H | 29 | #define KABC_RESOURCELDAP_H |
30 | 30 | ||
31 | 31 | ||
32 | #include <lber.h> | 32 | #include <lber.h> |
33 | #include <ldap.h> | 33 | #include <ldap.h> |
34 | 34 | ||
35 | #include "addressbook.h" | 35 | #include "addressbook.h" |
36 | #include "resource.h" | 36 | #include "resource.h" |
37 | 37 | ||
38 | class KConfig; | 38 | class KConfig; |
39 | 39 | ||
40 | namespace KABC { | 40 | namespace KABC { |
41 | 41 | ||
42 | class ResourceLDAP : public Resource | 42 | class ResourceLDAP : public Resource |
43 | { | 43 | { |
44 | public: | 44 | public: |
45 | 45 | ||
46 | ResourceLDAP( const KConfig*, bool syncable ); | 46 | ResourceLDAP( const KConfig* ); |
47 | 47 | ||
48 | virtual void writeConfig( KConfig* ); | 48 | virtual void writeConfig( KConfig* ); |
49 | 49 | ||
50 | virtual bool doOpen(); | 50 | virtual bool doOpen(); |
51 | virtual void doClose(); | 51 | virtual void doClose(); |
52 | 52 | ||
53 | virtual Ticket *requestSaveTicket(); | 53 | virtual Ticket *requestSaveTicket(); |
54 | 54 | ||
55 | virtual bool load(); | 55 | virtual bool load(); |
56 | virtual bool save( Ticket * ); | 56 | virtual bool save( Ticket * ); |
57 | 57 | ||
58 | virtual void removeAddressee( const Addressee& addr ); | 58 | virtual void removeAddressee( const Addressee& addr ); |
59 | 59 | ||
60 | void setUser( const QString &user ); | 60 | void setUser( const QString &user ); |
61 | QString user() const; | 61 | QString user() const; |
62 | 62 | ||
63 | void setPassword( const QString &password ); | 63 | void setPassword( const QString &password ); |
64 | QString password() const; | 64 | QString password() const; |
65 | 65 | ||
66 | void setDn( const QString &dn ); | 66 | void setDn( const QString &dn ); |
67 | QString dn() const; | 67 | QString dn() const; |
68 | 68 | ||
69 | void setHost( const QString &host ); | 69 | void setHost( const QString &host ); |
70 | QString host() const; | 70 | QString host() const; |
71 | 71 | ||
72 | void setPort( int port ); | 72 | void setPort( int port ); |
73 | int port() const; | 73 | int port() const; |
74 | 74 | ||
75 | void setFilter( const QString &filter ); | 75 | void setFilter( const QString &filter ); |
76 | QString filter() const; | 76 | QString filter() const; |
77 | 77 | ||
78 | void setIsAnonymous( bool value ); | 78 | void setIsAnonymous( bool value ); |
79 | bool isAnonymous() const; | 79 | bool isAnonymous() const; |
80 | 80 | ||
81 | void setAttributes( const QMap<QString, QString> &attributes ); | 81 | void setAttributes( const QMap<QString, QString> &attributes ); |
82 | QMap<QString, QString> attributes() const; | 82 | QMap<QString, QString> attributes() const; |
83 | 83 | ||
84 | private: | 84 | private: |
85 | QString mUser; | 85 | QString mUser; |
86 | QString mPassword; | 86 | QString mPassword; |
87 | QString mDn; | 87 | QString mDn; |
88 | QString mHost; | 88 | QString mHost; |
89 | QString mFilter; | 89 | QString mFilter; |
90 | int mPort; | 90 | int mPort; |
91 | bool mAnonymous; | 91 | bool mAnonymous; |
92 | QMap<QString, QString> mAttributes; | 92 | QMap<QString, QString> mAttributes; |
93 | 93 | ||
94 | LDAP *mLdap; | 94 | LDAP *mLdap; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | #endif | 99 | #endif |
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp index 22237dc..f610b38 100644 --- a/kabc/plugins/opie/resourceopie.cpp +++ b/kabc/plugins/opie/resourceopie.cpp | |||
@@ -1,211 +1,210 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | 31 | ||
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | #include <kapplication.h> | 37 | #include <kapplication.h> |
38 | #include <kconfig.h> | 38 | #include <kconfig.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | //US #include <ksavefile.h> | 41 | //US #include <ksavefile.h> |
42 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | 44 | ||
45 | //US #include "formatfactory.h" | 45 | //US #include "formatfactory.h" |
46 | //US #include <qpe/qpeapplication.h> | 46 | //US #include <qpe/qpeapplication.h> |
47 | 47 | ||
48 | #include <opie/ocontactaccess.h> | 48 | #include <opie/ocontactaccess.h> |
49 | #include <opie/ocontactaccessbackend_xml.h> | 49 | #include <opie/ocontactaccessbackend_xml.h> |
50 | 50 | ||
51 | #include "resourceopieconfig.h" | 51 | #include "resourceopieconfig.h" |
52 | #include "stdaddressbook.h" | 52 | #include "stdaddressbook.h" |
53 | #include "syncprefwidget.h" | ||
54 | 53 | ||
55 | #include "opieconverter.h" | 54 | #include "opieconverter.h" |
56 | 55 | ||
57 | #include "resourceopie.h" | 56 | #include "resourceopie.h" |
58 | 57 | ||
59 | using namespace KABC; | 58 | using namespace KABC; |
60 | extern "C" | 59 | extern "C" |
61 | { | 60 | { |
62 | void *init_microkabc_opie() | 61 | void *init_microkabc_opie() |
63 | { | 62 | { |
64 | return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidgetContainer>(); | 63 | return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); |
65 | } | 64 | } |
66 | } | 65 | } |
67 | 66 | ||
68 | ResourceOpie::ResourceOpie( const KConfig *config, bool syncable ) | 67 | ResourceOpie::ResourceOpie( const KConfig *config ) |
69 | : Resource( config, syncable ), mAccess(0), mConverter (0) | 68 | : Resource( config ), mAccess(0), mConverter (0) |
70 | { | 69 | { |
71 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 70 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
72 | 71 | ||
73 | KConfig *cfg = (KConfig *)config; | 72 | KConfig *cfg = (KConfig *)config; |
74 | if ( cfg ) { | 73 | if ( cfg ) { |
75 | fileName = cfg->readEntry( "FileName", fileName ); | 74 | fileName = cfg->readEntry( "FileName", fileName ); |
76 | 75 | ||
77 | } | 76 | } |
78 | 77 | ||
79 | init( fileName ); | 78 | init( fileName ); |
80 | } | 79 | } |
81 | 80 | ||
82 | ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) | 81 | ResourceOpie::ResourceOpie( const QString &fileName ) |
83 | : Resource( 0, syncable ) | 82 | : Resource( 0 ) |
84 | { | 83 | { |
85 | init( fileName ); | 84 | init( fileName ); |
86 | } | 85 | } |
87 | 86 | ||
88 | void ResourceOpie::init( const QString &fileName ) | 87 | void ResourceOpie::init( const QString &fileName ) |
89 | { | 88 | { |
90 | qDebug("ResourceOpie::init()"); | 89 | qDebug("ResourceOpie::init()"); |
91 | 90 | ||
92 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 91 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
93 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 92 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
94 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 93 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
95 | 94 | ||
96 | setFileName( fileName ); | 95 | setFileName( fileName ); |
97 | } | 96 | } |
98 | 97 | ||
99 | ResourceOpie::~ResourceOpie() | 98 | ResourceOpie::~ResourceOpie() |
100 | { | 99 | { |
101 | if (mConverter != 0) | 100 | if (mConverter != 0) |
102 | delete mConverter; | 101 | delete mConverter; |
103 | 102 | ||
104 | if(mAccess != 0) | 103 | if(mAccess != 0) |
105 | delete mAccess; | 104 | delete mAccess; |
106 | } | 105 | } |
107 | 106 | ||
108 | void ResourceOpie::writeConfig( KConfig *config ) | 107 | void ResourceOpie::writeConfig( KConfig *config ) |
109 | { | 108 | { |
110 | Resource::writeConfig( config ); | 109 | Resource::writeConfig( config ); |
111 | 110 | ||
112 | config->writeEntry( "FileName", fileName() ); | 111 | config->writeEntry( "FileName", fileName() ); |
113 | } | 112 | } |
114 | 113 | ||
115 | Ticket *ResourceOpie::requestSaveTicket() | 114 | Ticket *ResourceOpie::requestSaveTicket() |
116 | { | 115 | { |
117 | kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; | 116 | kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; |
118 | 117 | ||
119 | qDebug("ResourceOpie::requestSaveTicket: %s", fileName().latin1()); | 118 | qDebug("ResourceOpie::requestSaveTicket: %s", fileName().latin1()); |
120 | 119 | ||
121 | if ( !addressBook() ) return 0; | 120 | if ( !addressBook() ) return 0; |
122 | 121 | ||
123 | if ( !lock( fileName() ) ) { | 122 | if ( !lock( fileName() ) ) { |
124 | kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" | 123 | kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" |
125 | << fileName() << "'" << endl; | 124 | << fileName() << "'" << endl; |
126 | return 0; | 125 | return 0; |
127 | } | 126 | } |
128 | return createTicket( this ); | 127 | return createTicket( this ); |
129 | } | 128 | } |
130 | 129 | ||
131 | 130 | ||
132 | bool ResourceOpie::doOpen() | 131 | bool ResourceOpie::doOpen() |
133 | { | 132 | { |
134 | qDebug("ResourceOpie::doOpen: %s", fileName().latin1()); | 133 | qDebug("ResourceOpie::doOpen: %s", fileName().latin1()); |
135 | 134 | ||
136 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", fileName() ); | 135 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", fileName() ); |
137 | mAccess = new OContactAccess("KDEPim/Pi", 0l, backend, false); | 136 | mAccess = new OContactAccess("KDEPim/Pi", 0l, backend, false); |
138 | 137 | ||
139 | if ( !mAccess ) { | 138 | if ( !mAccess ) { |
140 | qDebug("Unable to load file() %s", fileName().latin1()); | 139 | qDebug("Unable to load file() %s", fileName().latin1()); |
141 | return false; | 140 | return false; |
142 | } | 141 | } |
143 | 142 | ||
144 | mAccess->setReadAhead( 32 ); // Use ReadAhead-Cache if available | 143 | mAccess->setReadAhead( 32 ); // Use ReadAhead-Cache if available |
145 | 144 | ||
146 | 145 | ||
147 | if (mConverter == 0) | 146 | if (mConverter == 0) |
148 | { | 147 | { |
149 | mConverter = new OpieConverter(); | 148 | mConverter = new OpieConverter(); |
150 | bool res = mConverter->init(); | 149 | bool res = mConverter->init(); |
151 | if ( !res ) | 150 | if ( !res ) |
152 | { | 151 | { |
153 | qDebug("Unable to initialize opie converter. Most likely a problem with the category file"); | 152 | qDebug("Unable to initialize opie converter. Most likely a problem with the category file"); |
154 | delete mAccess; | 153 | delete mAccess; |
155 | mAccess = 0; | 154 | mAccess = 0; |
156 | return false; | 155 | return false; |
157 | } | 156 | } |
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | 160 | ||
162 | return true; | 161 | return true; |
163 | } | 162 | } |
164 | 163 | ||
165 | void ResourceOpie::doClose() | 164 | void ResourceOpie::doClose() |
166 | { | 165 | { |
167 | qDebug("ResourceOpie::doClose: %s", fileName().latin1()); | 166 | qDebug("ResourceOpie::doClose: %s", fileName().latin1()); |
168 | 167 | ||
169 | if(mAccess) | 168 | if(mAccess) |
170 | { | 169 | { |
171 | delete mAccess; | 170 | delete mAccess; |
172 | mAccess = 0; | 171 | mAccess = 0; |
173 | } | 172 | } |
174 | // it seems so, that deletion of access deletes backend as well | 173 | // it seems so, that deletion of access deletes backend as well |
175 | //delete backend; | 174 | //delete backend; |
176 | 175 | ||
177 | return; | 176 | return; |
178 | 177 | ||
179 | } | 178 | } |
180 | 179 | ||
181 | 180 | ||
182 | bool ResourceOpie::load() | 181 | bool ResourceOpie::load() |
183 | { | 182 | { |
184 | qDebug("ResourceOpie::load: %s", fileName().latin1()); | 183 | qDebug("ResourceOpie::load: %s", fileName().latin1()); |
185 | 184 | ||
186 | bool res = false; | 185 | bool res = false; |
187 | 186 | ||
188 | OContactAccess::List::Iterator it; | 187 | OContactAccess::List::Iterator it; |
189 | OContactAccess::List allList = mAccess->allRecords(); | 188 | OContactAccess::List allList = mAccess->allRecords(); |
190 | for ( it = allList.begin(); it != allList.end(); ++it ) | 189 | for ( it = allList.begin(); it != allList.end(); ++it ) |
191 | { | 190 | { |
192 | const OContact c = (*it); | 191 | const OContact c = (*it); |
193 | 192 | ||
194 | KABC::Addressee addressee; | 193 | KABC::Addressee addressee; |
195 | 194 | ||
196 | res = mConverter->opieToAddressee( c, addressee ); | 195 | res = mConverter->opieToAddressee( c, addressee ); |
197 | 196 | ||
198 | if ( !addressee.isEmpty() && res ) | 197 | if ( !addressee.isEmpty() && res ) |
199 | { | 198 | { |
200 | addressee.setResource( this ); | 199 | addressee.setResource( this ); |
201 | addressBook()->insertAddressee( addressee ); | 200 | addressBook()->insertAddressee( addressee ); |
202 | } | 201 | } |
203 | 202 | ||
204 | } | 203 | } |
205 | 204 | ||
206 | 205 | ||
207 | return true; | 206 | return true; |
208 | } | 207 | } |
209 | 208 | ||
210 | bool ResourceOpie::save( Ticket *ticket ) | 209 | bool ResourceOpie::save( Ticket *ticket ) |
211 | { | 210 | { |
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h index d5b4ebd..9d05c70 100644 --- a/kabc/plugins/opie/resourceopie.h +++ b/kabc/plugins/opie/resourceopie.h | |||
@@ -1,146 +1,146 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #ifndef KABC_RESOURCEOPIE_H | 29 | #ifndef KABC_RESOURCEOPIE_H |
30 | #define KABC_RESOURCEOPIE_H | 30 | #define KABC_RESOURCEOPIE_H |
31 | 31 | ||
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdirwatch.h> | 33 | #include <kdirwatch.h> |
34 | 34 | ||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | 36 | ||
37 | #include "resource.h" | 37 | #include "resource.h" |
38 | 38 | ||
39 | 39 | ||
40 | class OContactAccess; | 40 | class OContactAccess; |
41 | 41 | ||
42 | namespace KABC { | 42 | namespace KABC { |
43 | 43 | ||
44 | class ResourceConfigWidget; | 44 | class ResourceConfigWidget; |
45 | class OpieConverter; | 45 | class OpieConverter; |
46 | /** | 46 | /** |
47 | @internal | 47 | @internal |
48 | */ | 48 | */ |
49 | class ResourceOpie : public Resource | 49 | class ResourceOpie : public Resource |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | public: | 53 | public: |
54 | 54 | ||
55 | /** | 55 | /** |
56 | Constructor. | 56 | Constructor. |
57 | 57 | ||
58 | @param cfg The config object where custom resource settings are stored. | 58 | @param cfg The config object where custom resource settings are stored. |
59 | */ | 59 | */ |
60 | ResourceOpie( const KConfig *cfg, bool syncable ); | 60 | ResourceOpie( const KConfig *cfg ); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | Construct file resource on file @arg fileName using format @arg formatName. | 63 | Construct file resource on file @arg fileName using format @arg formatName. |
64 | */ | 64 | */ |
65 | ResourceOpie( const QString &fileName, bool syncable ); | 65 | ResourceOpie( const QString &fileName ); |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Destructor. | 68 | * Destructor. |
69 | */ | 69 | */ |
70 | ~ResourceOpie(); | 70 | ~ResourceOpie(); |
71 | 71 | ||
72 | /** | 72 | /** |
73 | Writes the config back. | 73 | Writes the config back. |
74 | */ | 74 | */ |
75 | virtual void writeConfig( KConfig *cfg ); | 75 | virtual void writeConfig( KConfig *cfg ); |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Tries to open the file and checks for the proper format. | 78 | * Tries to open the file and checks for the proper format. |
79 | * This method should be called before @ref load(). | 79 | * This method should be called before @ref load(). |
80 | */ | 80 | */ |
81 | virtual bool doOpen(); | 81 | virtual bool doOpen(); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Closes the file again. | 84 | * Closes the file again. |
85 | */ | 85 | */ |
86 | virtual void doClose(); | 86 | virtual void doClose(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Requests a save ticket, that is used by @ref save() | 89 | * Requests a save ticket, that is used by @ref save() |
90 | */ | 90 | */ |
91 | virtual Ticket *requestSaveTicket(); | 91 | virtual Ticket *requestSaveTicket(); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Loads all addressees from file to the address book. | 94 | * Loads all addressees from file to the address book. |
95 | * Returns true if all addressees could be loaded otherwise false. | 95 | * Returns true if all addressees could be loaded otherwise false. |
96 | */ | 96 | */ |
97 | virtual bool load(); | 97 | virtual bool load(); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Saves all addresses from address book to file. | 100 | * Saves all addresses from address book to file. |
101 | * Returns true if all addressees could be saved otherwise false. | 101 | * Returns true if all addressees could be saved otherwise false. |
102 | * | 102 | * |
103 | * @param ticket The ticket returned by @ref requestSaveTicket() | 103 | * @param ticket The ticket returned by @ref requestSaveTicket() |
104 | */ | 104 | */ |
105 | virtual bool save( Ticket *ticket ); | 105 | virtual bool save( Ticket *ticket ); |
106 | 106 | ||
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Remove a addressee from its source. | 109 | * Remove a addressee from its source. |
110 | * This method is mainly called by KABC::AddressBook. | 110 | * This method is mainly called by KABC::AddressBook. |
111 | */ | 111 | */ |
112 | virtual void removeAddressee( const Addressee& addr ); | 112 | virtual void removeAddressee( const Addressee& addr ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Set name of file to be used for saving. | 115 | * Set name of file to be used for saving. |
116 | */ | 116 | */ |
117 | virtual void setFileName( const QString & ); | 117 | virtual void setFileName( const QString & ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
122 | */ | 122 | */ |
123 | virtual void cleanUp(); | 123 | virtual void cleanUp(); |
124 | 124 | ||
125 | 125 | ||
126 | protected slots: | 126 | protected slots: |
127 | void fileChanged(); | 127 | void fileChanged(); |
128 | 128 | ||
129 | protected: | 129 | protected: |
130 | void init( const QString &fileName ); | 130 | void init( const QString &fileName ); |
131 | 131 | ||
132 | bool lock( const QString &fileName ); | 132 | bool lock( const QString &fileName ); |
133 | void unlock( const QString &fileName ); | 133 | void unlock( const QString &fileName ); |
134 | 134 | ||
135 | private: | 135 | private: |
136 | OContactAccess* mAccess; | 136 | OContactAccess* mAccess; |
137 | OpieConverter* mConverter; | 137 | OpieConverter* mConverter; |
138 | 138 | ||
139 | QString mLockUniqueName; | 139 | QString mLockUniqueName; |
140 | 140 | ||
141 | KDirWatch mDirWatch; | 141 | KDirWatch mDirWatch; |
142 | }; | 142 | }; |
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | #endif | 146 | #endif |
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index f9cabcb..deb218b 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -1,202 +1,201 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | //US #include <qtimer.h> | 35 | //US #include <qtimer.h> |
36 | 36 | ||
37 | #include <kapplication.h> | 37 | #include <kapplication.h> |
38 | #include <kconfig.h> | 38 | #include <kconfig.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | //US #include <ksavefile.h> | 41 | //US #include <ksavefile.h> |
42 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | 44 | ||
45 | #include <qpe/pim/addressbookaccess.h> | 45 | #include <qpe/pim/addressbookaccess.h> |
46 | 46 | ||
47 | 47 | ||
48 | #include "resourceqtopiaconfig.h" | 48 | #include "resourceqtopiaconfig.h" |
49 | #include "stdaddressbook.h" | 49 | #include "stdaddressbook.h" |
50 | 50 | ||
51 | #include "qtopiaconverter.h" | 51 | #include "qtopiaconverter.h" |
52 | #include "syncprefwidget.h" | ||
53 | 52 | ||
54 | #include "resourceqtopia.h" | 53 | #include "resourceqtopia.h" |
55 | 54 | ||
56 | using namespace KABC; | 55 | using namespace KABC; |
57 | extern "C" | 56 | extern "C" |
58 | { | 57 | { |
59 | void *init_microkabc_qtopia() | 58 | void *init_microkabc_qtopia() |
60 | { | 59 | { |
61 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); | 60 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); |
62 | } | 61 | } |
63 | } | 62 | } |
64 | 63 | ||
65 | ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) | 64 | ResourceQtopia::ResourceQtopia( const KConfig *config ) |
66 | : Resource( config, syncable ), mConverter (0) | 65 | : Resource( config ), mConverter (0) |
67 | { | 66 | { |
68 | // 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 |
69 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 68 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
70 | init( fileName ); | 69 | init( fileName ); |
71 | } | 70 | } |
72 | 71 | ||
73 | ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) | 72 | ResourceQtopia::ResourceQtopia( const QString &fileName ) |
74 | : Resource( 0, syncable ) | 73 | : Resource( 0 ) |
75 | { | 74 | { |
76 | init( fileName ); | 75 | init( fileName ); |
77 | } | 76 | } |
78 | 77 | ||
79 | void ResourceQtopia::init( const QString &fileName ) | 78 | void ResourceQtopia::init( const QString &fileName ) |
80 | { | 79 | { |
81 | 80 | ||
82 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 81 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
83 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 82 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
84 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 83 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
85 | 84 | ||
86 | setFileName( fileName ); | 85 | setFileName( fileName ); |
87 | } | 86 | } |
88 | 87 | ||
89 | ResourceQtopia::~ResourceQtopia() | 88 | ResourceQtopia::~ResourceQtopia() |
90 | { | 89 | { |
91 | if (mConverter != 0) | 90 | if (mConverter != 0) |
92 | delete mConverter; | 91 | delete mConverter; |
93 | 92 | ||
94 | if(mAccess != 0) | 93 | if(mAccess != 0) |
95 | delete mAccess; | 94 | delete mAccess; |
96 | } | 95 | } |
97 | 96 | ||
98 | void ResourceQtopia::writeConfig( KConfig *config ) | 97 | void ResourceQtopia::writeConfig( KConfig *config ) |
99 | { | 98 | { |
100 | Resource::writeConfig( config ); | 99 | Resource::writeConfig( config ); |
101 | } | 100 | } |
102 | 101 | ||
103 | Ticket *ResourceQtopia::requestSaveTicket() | 102 | Ticket *ResourceQtopia::requestSaveTicket() |
104 | { | 103 | { |
105 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; | 104 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; |
106 | 105 | ||
107 | qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); | 106 | qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); |
108 | 107 | ||
109 | if ( !addressBook() ) return 0; | 108 | if ( !addressBook() ) return 0; |
110 | 109 | ||
111 | if ( !lock( fileName() ) ) { | 110 | if ( !lock( fileName() ) ) { |
112 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" | 111 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" |
113 | << fileName() << "'" << endl; | 112 | << fileName() << "'" << endl; |
114 | return 0; | 113 | return 0; |
115 | } | 114 | } |
116 | return createTicket( this ); | 115 | return createTicket( this ); |
117 | } | 116 | } |
118 | 117 | ||
119 | 118 | ||
120 | bool ResourceQtopia::doOpen() | 119 | bool ResourceQtopia::doOpen() |
121 | { | 120 | { |
122 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); | 121 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); |
123 | 122 | ||
124 | mAccess = new AddressBookAccess(); | 123 | mAccess = new AddressBookAccess(); |
125 | 124 | ||
126 | if ( !mAccess ) { | 125 | if ( !mAccess ) { |
127 | qDebug("Unable to load file() %s", fileName().latin1()); | 126 | qDebug("Unable to load file() %s", fileName().latin1()); |
128 | return false; | 127 | return false; |
129 | } | 128 | } |
130 | 129 | ||
131 | 130 | ||
132 | if (mConverter == 0) | 131 | if (mConverter == 0) |
133 | { | 132 | { |
134 | mConverter = new QtopiaConverter(); | 133 | mConverter = new QtopiaConverter(); |
135 | bool res = mConverter->init(); | 134 | bool res = mConverter->init(); |
136 | if ( !res ) | 135 | if ( !res ) |
137 | { | 136 | { |
138 | QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); | 137 | QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); |
139 | qDebug(msg); | 138 | qDebug(msg); |
140 | delete mAccess; | 139 | delete mAccess; |
141 | mAccess = 0; | 140 | mAccess = 0; |
142 | return false; | 141 | return false; |
143 | } | 142 | } |
144 | } | 143 | } |
145 | 144 | ||
146 | return true; | 145 | return true; |
147 | } | 146 | } |
148 | 147 | ||
149 | void ResourceQtopia::doClose() | 148 | void ResourceQtopia::doClose() |
150 | { | 149 | { |
151 | qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); | 150 | qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); |
152 | 151 | ||
153 | if(mAccess) | 152 | if(mAccess) |
154 | { | 153 | { |
155 | delete mAccess; | 154 | delete mAccess; |
156 | mAccess = 0; | 155 | mAccess = 0; |
157 | } | 156 | } |
158 | // it seems so, that deletion of access deletes backend as well | 157 | // it seems so, that deletion of access deletes backend as well |
159 | //delete backend; | 158 | //delete backend; |
160 | 159 | ||
161 | return; | 160 | return; |
162 | } | 161 | } |
163 | 162 | ||
164 | bool ResourceQtopia::load() | 163 | bool ResourceQtopia::load() |
165 | { | 164 | { |
166 | qDebug("ResourceQtopia::load: %s", fileName().latin1()); | 165 | qDebug("ResourceQtopia::load: %s", fileName().latin1()); |
167 | 166 | ||
168 | AddressBookIterator it(*mAccess); | 167 | AddressBookIterator it(*mAccess); |
169 | const PimContact* contact; | 168 | const PimContact* contact; |
170 | bool res; | 169 | bool res; |
171 | 170 | ||
172 | for (contact=it.toFirst(); it.current(); ++it) | 171 | for (contact=it.toFirst(); it.current(); ++it) |
173 | { | 172 | { |
174 | contact = it.current(); | 173 | contact = it.current(); |
175 | 174 | ||
176 | KABC::Addressee addressee; | 175 | KABC::Addressee addressee; |
177 | 176 | ||
178 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); | 177 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); |
179 | 178 | ||
180 | if ( !addressee.isEmpty() && res ) | 179 | if ( !addressee.isEmpty() && res ) |
181 | { | 180 | { |
182 | addressee.setResource( this ); | 181 | addressee.setResource( this ); |
183 | addressBook()->insertAddressee( addressee ); | 182 | addressBook()->insertAddressee( addressee ); |
184 | } | 183 | } |
185 | } | 184 | } |
186 | 185 | ||
187 | return true; | 186 | return true; |
188 | } | 187 | } |
189 | 188 | ||
190 | bool ResourceQtopia::save( Ticket *ticket ) | 189 | bool ResourceQtopia::save( Ticket *ticket ) |
191 | { | 190 | { |
192 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); | 191 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); |
193 | 192 | ||
194 | mDirWatch.stopScan(); | 193 | mDirWatch.stopScan(); |
195 | 194 | ||
196 | KABC::AddressBook::Iterator it; | 195 | KABC::AddressBook::Iterator it; |
197 | bool res; | 196 | bool res; |
198 | 197 | ||
199 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 198 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
200 | PimContact c; | 199 | PimContact c; |
201 | KABC::Addressee addressee = (*it); | 200 | KABC::Addressee addressee = (*it); |
202 | 201 | ||
diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h index eace280..ff6350d 100644 --- a/kabc/plugins/qtopia/resourceqtopia.h +++ b/kabc/plugins/qtopia/resourceqtopia.h | |||
@@ -1,145 +1,145 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #ifndef KABC_RESOURCEOPIE_H | 29 | #ifndef KABC_RESOURCEOPIE_H |
30 | #define KABC_RESOURCEOPIE_H | 30 | #define KABC_RESOURCEOPIE_H |
31 | 31 | ||
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdirwatch.h> | 33 | #include <kdirwatch.h> |
34 | 34 | ||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | 36 | ||
37 | #include "resource.h" | 37 | #include "resource.h" |
38 | 38 | ||
39 | class AddressBookAccess; | 39 | class AddressBookAccess; |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | 42 | ||
43 | //US class FormatPlugin; | 43 | //US class FormatPlugin; |
44 | class ResourceConfigWidget; | 44 | class ResourceConfigWidget; |
45 | class QtopiaConverter; | 45 | class QtopiaConverter; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | @internal | 48 | @internal |
49 | */ | 49 | */ |
50 | class ResourceQtopia : public Resource | 50 | class ResourceQtopia : public Resource |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | 55 | ||
56 | /** | 56 | /** |
57 | Constructor. | 57 | Constructor. |
58 | 58 | ||
59 | @param cfg The config object where custom resource settings are stored. | 59 | @param cfg The config object where custom resource settings are stored. |
60 | */ | 60 | */ |
61 | ResourceQtopia( const KConfig *cfg, bool syncable ); | 61 | ResourceQtopia( const KConfig *cfg ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | Construct file resource on file @arg fileName using format @arg formatName. | 64 | Construct file resource on file @arg fileName using format @arg formatName. |
65 | */ | 65 | */ |
66 | ResourceQtopia( const QString &fileName, bool syncable ); | 66 | ResourceQtopia( const QString &fileName ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Destructor. | 69 | * Destructor. |
70 | */ | 70 | */ |
71 | ~ResourceQtopia(); | 71 | ~ResourceQtopia(); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Writes the config back. | 74 | Writes the config back. |
75 | */ | 75 | */ |
76 | virtual void writeConfig( KConfig *cfg ); | 76 | virtual void writeConfig( KConfig *cfg ); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Tries to open the file and checks for the proper format. | 79 | * Tries to open the file and checks for the proper format. |
80 | * This method should be called before @ref load(). | 80 | * This method should be called before @ref load(). |
81 | */ | 81 | */ |
82 | virtual bool doOpen(); | 82 | virtual bool doOpen(); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Closes the file again. | 85 | * Closes the file again. |
86 | */ | 86 | */ |
87 | virtual void doClose(); | 87 | virtual void doClose(); |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Requests a save ticket, that is used by @ref save() | 90 | * Requests a save ticket, that is used by @ref save() |
91 | */ | 91 | */ |
92 | virtual Ticket *requestSaveTicket(); | 92 | virtual Ticket *requestSaveTicket(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Loads all addressees from file to the address book. | 95 | * Loads all addressees from file to the address book. |
96 | * Returns true if all addressees could be loaded otherwise false. | 96 | * Returns true if all addressees could be loaded otherwise false. |
97 | */ | 97 | */ |
98 | virtual bool load(); | 98 | virtual bool load(); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Saves all addresses from address book to file. | 101 | * Saves all addresses from address book to file. |
102 | * Returns true if all addressees could be saved otherwise false. | 102 | * Returns true if all addressees could be saved otherwise false. |
103 | * | 103 | * |
104 | * @param ticket The ticket returned by @ref requestSaveTicket() | 104 | * @param ticket The ticket returned by @ref requestSaveTicket() |
105 | */ | 105 | */ |
106 | virtual bool save( Ticket *ticket ); | 106 | virtual bool save( Ticket *ticket ); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Remove a addressee from its source. | 109 | * Remove a addressee from its source. |
110 | * This method is mainly called by KABC::AddressBook. | 110 | * This method is mainly called by KABC::AddressBook. |
111 | */ | 111 | */ |
112 | virtual void removeAddressee( const Addressee& addr ); | 112 | virtual void removeAddressee( const Addressee& addr ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Set name of file to be used for saving. | 115 | * Set name of file to be used for saving. |
116 | */ | 116 | */ |
117 | virtual void setFileName( const QString & ); | 117 | virtual void setFileName( const QString & ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
122 | */ | 122 | */ |
123 | virtual void cleanUp(); | 123 | virtual void cleanUp(); |
124 | 124 | ||
125 | protected slots: | 125 | protected slots: |
126 | void fileChanged(); | 126 | void fileChanged(); |
127 | 127 | ||
128 | protected: | 128 | protected: |
129 | void init( const QString &fileName ); | 129 | void init( const QString &fileName ); |
130 | 130 | ||
131 | bool lock( const QString &fileName ); | 131 | bool lock( const QString &fileName ); |
132 | void unlock( const QString &fileName ); | 132 | void unlock( const QString &fileName ); |
133 | 133 | ||
134 | private: | 134 | private: |
135 | AddressBookAccess* mAccess; | 135 | AddressBookAccess* mAccess; |
136 | QtopiaConverter* mConverter; | 136 | QtopiaConverter* mConverter; |
137 | 137 | ||
138 | QString mLockUniqueName; | 138 | QString mLockUniqueName; |
139 | 139 | ||
140 | KDirWatch mDirWatch; | 140 | KDirWatch mDirWatch; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | } | 143 | } |
144 | 144 | ||
145 | #endif | 145 | #endif |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index c013f52..2cdf4bf 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -1,197 +1,195 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | 31 | ||
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | //US #include <qtimer.h> | 36 | //US #include <qtimer.h> |
37 | 37 | ||
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kdebug.h> | 40 | #include <kdebug.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 42 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | #include <sl/slzdb.h> | 46 | #include <sl/slzdb.h> |
47 | 47 | ||
48 | #include <libkdepim/ksyncprofile.h> | 48 | #include <libkdepim/ksyncprofile.h> |
49 | 49 | ||
50 | #include "resourcesharpdtmconfig.h" | 50 | #include "resourcesharpdtmconfig.h" |
51 | #include "resourcesharpdtm.h" | 51 | #include "resourcesharpdtm.h" |
52 | 52 | ||
53 | #include "syncprefwidget.h" | ||
54 | |||
55 | #include "stdaddressbook.h" | 53 | #include "stdaddressbook.h" |
56 | 54 | ||
57 | #include "sharpdtmconverter.h" | 55 | #include "sharpdtmconverter.h" |
58 | //#define ALLOW_LOCKING | 56 | //#define ALLOW_LOCKING |
59 | using namespace KABC; | 57 | using namespace KABC; |
60 | extern "C" | 58 | extern "C" |
61 | { | 59 | { |
62 | void *init_microkabc_sharpdtm() | 60 | void *init_microkabc_sharpdtm() |
63 | { | 61 | { |
64 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); | 62 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); |
65 | } | 63 | } |
66 | } | 64 | } |
67 | 65 | ||
68 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) | 66 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) |
69 | : Resource( config, syncable ), mConverter (0) | 67 | : Resource( config ), mConverter (0) |
70 | { | 68 | { |
71 | // we can not choose the filename. Therefore use the default to display | 69 | // we can not choose the filename. Therefore use the default to display |
72 | 70 | ||
73 | QString fileName = SlZDataBase::addressbookFileName(); | 71 | QString fileName = SlZDataBase::addressbookFileName(); |
74 | init( fileName ); | 72 | init( fileName ); |
75 | } | 73 | } |
76 | 74 | ||
77 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) | 75 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) |
78 | : Resource( 0, syncable ) | 76 | : Resource( 0, syncable ) |
79 | { | 77 | { |
80 | init( fileName ); | 78 | init( fileName ); |
81 | } | 79 | } |
82 | 80 | ||
83 | void ResourceSharpDTM::init( const QString &fileName ) | 81 | void ResourceSharpDTM::init( const QString &fileName ) |
84 | { | 82 | { |
85 | 83 | ||
86 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 84 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
87 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 85 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
88 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 86 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
89 | 87 | ||
90 | setFileName( fileName ); | 88 | setFileName( fileName ); |
91 | } | 89 | } |
92 | 90 | ||
93 | ResourceSharpDTM::~ResourceSharpDTM() | 91 | ResourceSharpDTM::~ResourceSharpDTM() |
94 | { | 92 | { |
95 | if (mConverter != 0) | 93 | if (mConverter != 0) |
96 | delete mConverter; | 94 | delete mConverter; |
97 | 95 | ||
98 | if(mAccess != 0) | 96 | if(mAccess != 0) |
99 | delete mAccess; | 97 | delete mAccess; |
100 | } | 98 | } |
101 | 99 | ||
102 | void ResourceSharpDTM::writeConfig( KConfig *config ) | 100 | void ResourceSharpDTM::writeConfig( KConfig *config ) |
103 | { | 101 | { |
104 | Resource::writeConfig( config ); | 102 | Resource::writeConfig( config ); |
105 | } | 103 | } |
106 | 104 | ||
107 | Ticket *ResourceSharpDTM::requestSaveTicket() | 105 | Ticket *ResourceSharpDTM::requestSaveTicket() |
108 | { | 106 | { |
109 | 107 | ||
110 | 108 | ||
111 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); | 109 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); |
112 | 110 | ||
113 | if ( !addressBook() ) return 0; | 111 | if ( !addressBook() ) return 0; |
114 | 112 | ||
115 | #ifdef ALLOW_LOCKING | 113 | #ifdef ALLOW_LOCKING |
116 | if ( !lock( fileName() ) ) { | 114 | if ( !lock( fileName() ) ) { |
117 | qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); | 115 | qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); |
118 | return 0; | 116 | return 0; |
119 | } | 117 | } |
120 | #endif | 118 | #endif |
121 | return createTicket( this ); | 119 | return createTicket( this ); |
122 | } | 120 | } |
123 | 121 | ||
124 | 122 | ||
125 | bool ResourceSharpDTM::doOpen() | 123 | bool ResourceSharpDTM::doOpen() |
126 | { | 124 | { |
127 | qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); | 125 | qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); |
128 | 126 | ||
129 | // the last parameter in the SlZDataBase constructor means "readonly" | 127 | // the last parameter in the SlZDataBase constructor means "readonly" |
130 | mAccess = new SlZDataBase(fileName(), | 128 | mAccess = new SlZDataBase(fileName(), |
131 | SlZDataBase::addressbookItems(), | 129 | SlZDataBase::addressbookItems(), |
132 | NULL, false); | 130 | NULL, false); |
133 | 131 | ||
134 | if ( !mAccess ) { | 132 | if ( !mAccess ) { |
135 | qDebug("Unable to load file() %s", fileName().latin1()); | 133 | qDebug("Unable to load file() %s", fileName().latin1()); |
136 | return false; | 134 | return false; |
137 | } | 135 | } |
138 | 136 | ||
139 | if (mConverter == 0) | 137 | if (mConverter == 0) |
140 | { | 138 | { |
141 | mConverter = new SharpDTMConverter(); | 139 | mConverter = new SharpDTMConverter(); |
142 | bool res = mConverter->init(); | 140 | bool res = mConverter->init(); |
143 | if ( !res ) | 141 | if ( !res ) |
144 | { | 142 | { |
145 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | 143 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); |
146 | 144 | ||
147 | qDebug(msg); | 145 | qDebug(msg); |
148 | delete mAccess; | 146 | delete mAccess; |
149 | mAccess = 0; | 147 | mAccess = 0; |
150 | return false; | 148 | return false; |
151 | } | 149 | } |
152 | } | 150 | } |
153 | 151 | ||
154 | return true; | 152 | return true; |
155 | } | 153 | } |
156 | 154 | ||
157 | void ResourceSharpDTM::doClose() | 155 | void ResourceSharpDTM::doClose() |
158 | { | 156 | { |
159 | qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); | 157 | qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); |
160 | 158 | ||
161 | if(mAccess) | 159 | if(mAccess) |
162 | { | 160 | { |
163 | delete mAccess; | 161 | delete mAccess; |
164 | mAccess = 0; | 162 | mAccess = 0; |
165 | } | 163 | } |
166 | // it seems so, that deletion of access deletes backend as well | 164 | // it seems so, that deletion of access deletes backend as well |
167 | //delete backend; | 165 | //delete backend; |
168 | 166 | ||
169 | return; | 167 | return; |
170 | } | 168 | } |
171 | 169 | ||
172 | bool ResourceSharpDTM::load() | 170 | bool ResourceSharpDTM::load() |
173 | { | 171 | { |
174 | qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); | 172 | qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); |
175 | 173 | ||
176 | bool res = false; | 174 | bool res = false; |
177 | 175 | ||
178 | CardId id; | 176 | CardId id; |
179 | 177 | ||
180 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) | 178 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) |
181 | { | 179 | { |
182 | id = mAccess->cardId(); | 180 | id = mAccess->cardId(); |
183 | 181 | ||
184 | KABC::Addressee addressee; | 182 | KABC::Addressee addressee; |
185 | 183 | ||
186 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 184 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
187 | 185 | ||
188 | if ( !addressee.isEmpty() && res ) | 186 | if ( !addressee.isEmpty() && res ) |
189 | { | 187 | { |
190 | addressee.setResource( this ); | 188 | addressee.setResource( this ); |
191 | addressBook()->insertAddressee( addressee ); | 189 | addressBook()->insertAddressee( addressee ); |
192 | } | 190 | } |
193 | } | 191 | } |
194 | 192 | ||
195 | return true; | 193 | return true; |
196 | } | 194 | } |
197 | 195 | ||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h index f386e69..64d06f9 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.h +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h | |||
@@ -1,146 +1,146 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #ifndef KABC_RESOURCESHARPDTM_H | 29 | #ifndef KABC_RESOURCESHARPDTM_H |
30 | #define KABC_RESOURCESHARPDTM_H | 30 | #define KABC_RESOURCESHARPDTM_H |
31 | 31 | ||
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdirwatch.h> | 33 | #include <kdirwatch.h> |
34 | 34 | ||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | 36 | ||
37 | #include "resource.h" | 37 | #include "resource.h" |
38 | 38 | ||
39 | 39 | ||
40 | class SlZDataBase; | 40 | class SlZDataBase; |
41 | 41 | ||
42 | namespace KABC { | 42 | namespace KABC { |
43 | 43 | ||
44 | class ResourceConfigWidget; | 44 | class ResourceConfigWidget; |
45 | class SharpDTMConverter; | 45 | class SharpDTMConverter; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | @internal | 48 | @internal |
49 | */ | 49 | */ |
50 | class ResourceSharpDTM : public Resource | 50 | class ResourceSharpDTM : public Resource |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | 55 | ||
56 | /** | 56 | /** |
57 | Constructor. | 57 | Constructor. |
58 | 58 | ||
59 | @param cfg The config object where custom resource settings are stored. | 59 | @param cfg The config object where custom resource settings are stored. |
60 | */ | 60 | */ |
61 | ResourceSharpDTM( const KConfig *cfg, bool syncable ); | 61 | ResourceSharpDTM( const KConfig *cfg ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | Construct file resource on file @arg fileName using format @arg formatName. | 64 | Construct file resource on file @arg fileName using format @arg formatName. |
65 | */ | 65 | */ |
66 | ResourceSharpDTM( const QString &fileName, bool syncable ); | 66 | ResourceSharpDTM( const QString &fileName ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Destructor. | 69 | * Destructor. |
70 | */ | 70 | */ |
71 | ~ResourceSharpDTM(); | 71 | ~ResourceSharpDTM(); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Writes the config back. | 74 | Writes the config back. |
75 | */ | 75 | */ |
76 | virtual void writeConfig( KConfig *cfg ); | 76 | virtual void writeConfig( KConfig *cfg ); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Tries to open the file and checks for the proper format. | 79 | * Tries to open the file and checks for the proper format. |
80 | * This method should be called before @ref load(). | 80 | * This method should be called before @ref load(). |
81 | */ | 81 | */ |
82 | virtual bool doOpen(); | 82 | virtual bool doOpen(); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Closes the file again. | 85 | * Closes the file again. |
86 | */ | 86 | */ |
87 | virtual void doClose(); | 87 | virtual void doClose(); |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Requests a save ticket, that is used by @ref save() | 90 | * Requests a save ticket, that is used by @ref save() |
91 | */ | 91 | */ |
92 | virtual Ticket *requestSaveTicket(); | 92 | virtual Ticket *requestSaveTicket(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Loads all addressees from file to the address book. | 95 | * Loads all addressees from file to the address book. |
96 | * Returns true if all addressees could be loaded otherwise false. | 96 | * Returns true if all addressees could be loaded otherwise false. |
97 | */ | 97 | */ |
98 | virtual bool load(); | 98 | virtual bool load(); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Saves all addresses from address book to file. | 101 | * Saves all addresses from address book to file. |
102 | * Returns true if all addressees could be saved otherwise false. | 102 | * Returns true if all addressees could be saved otherwise false. |
103 | * | 103 | * |
104 | * @param ticket The ticket returned by @ref requestSaveTicket() | 104 | * @param ticket The ticket returned by @ref requestSaveTicket() |
105 | */ | 105 | */ |
106 | virtual bool save( Ticket *ticket ); | 106 | virtual bool save( Ticket *ticket ); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Remove a addressee from its source. | 109 | * Remove a addressee from its source. |
110 | * This method is mainly called by KABC::AddressBook. | 110 | * This method is mainly called by KABC::AddressBook. |
111 | */ | 111 | */ |
112 | virtual void removeAddressee( const Addressee& addr ); | 112 | virtual void removeAddressee( const Addressee& addr ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Set name of file to be used for saving. | 115 | * Set name of file to be used for saving. |
116 | */ | 116 | */ |
117 | virtual void setFileName( const QString & ); | 117 | virtual void setFileName( const QString & ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
122 | */ | 122 | */ |
123 | virtual void cleanUp(); | 123 | virtual void cleanUp(); |
124 | 124 | ||
125 | 125 | ||
126 | protected slots: | 126 | protected slots: |
127 | void fileChanged(); | 127 | void fileChanged(); |
128 | 128 | ||
129 | protected: | 129 | protected: |
130 | void init( const QString &fileName ); | 130 | void init( const QString &fileName ); |
131 | 131 | ||
132 | bool lock( const QString &fileName ); | 132 | bool lock( const QString &fileName ); |
133 | void unlock( const QString &fileName ); | 133 | void unlock( const QString &fileName ); |
134 | 134 | ||
135 | private: | 135 | private: |
136 | SlZDataBase* mAccess; | 136 | SlZDataBase* mAccess; |
137 | SharpDTMConverter* mConverter; | 137 | SharpDTMConverter* mConverter; |
138 | 138 | ||
139 | QString mLockUniqueName; | 139 | QString mLockUniqueName; |
140 | 140 | ||
141 | KDirWatch mDirWatch; | 141 | KDirWatch mDirWatch; |
142 | }; | 142 | }; |
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | #endif | 146 | #endif |
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 7b91239..267cdaf 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -1,144 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <ksyncprofile.h> | ||
31 | |||
32 | #include "resource.h" | 30 | #include "resource.h" |
33 | 31 | ||
34 | using namespace KABC; | 32 | using namespace KABC; |
35 | 33 | ||
36 | Resource::Resource( const KConfig *config, bool syncable ) | 34 | Resource::Resource( const KConfig *config ) |
37 | : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) | 35 | : KRES::Resource( config ), mAddressBook( 0 ) |
38 | { | 36 | { |
39 | if(syncable == true) { | ||
40 | mSyncProfile = new KSyncProfile( ); | ||
41 | mSyncProfile->setName("pending" /*resourceName()*/); | ||
42 | mSyncProfile->readConfig( (KConfig *)config ); | ||
43 | } | ||
44 | } | 37 | } |
45 | 38 | ||
46 | Resource::~Resource() | 39 | Resource::~Resource() |
47 | { | 40 | { |
48 | if (mSyncProfile != 0) { | ||
49 | delete mSyncProfile; | ||
50 | } | ||
51 | } | 41 | } |
52 | 42 | ||
53 | void Resource::writeConfig( KConfig *config ) | 43 | void Resource::writeConfig( KConfig *config ) |
54 | { | 44 | { |
55 | KRES::Resource::writeConfig( config ); | 45 | KRES::Resource::writeConfig( config ); |
56 | |||
57 | if(mSyncProfile != 0) | ||
58 | mSyncProfile->writeConfig( config ); | ||
59 | } | 46 | } |
60 | 47 | ||
61 | 48 | ||
62 | void Resource::setAddressBook( AddressBook *ab ) | 49 | void Resource::setAddressBook( AddressBook *ab ) |
63 | { | 50 | { |
64 | mAddressBook = ab; | 51 | mAddressBook = ab; |
65 | } | 52 | } |
66 | 53 | ||
67 | AddressBook *Resource::addressBook() | 54 | AddressBook *Resource::addressBook() |
68 | { | 55 | { |
69 | return mAddressBook; | 56 | return mAddressBook; |
70 | } | 57 | } |
71 | 58 | ||
72 | bool Resource::doOpen() | 59 | bool Resource::doOpen() |
73 | { | 60 | { |
74 | return true; | 61 | return true; |
75 | } | 62 | } |
76 | 63 | ||
77 | void Resource::doClose() | 64 | void Resource::doClose() |
78 | { | 65 | { |
79 | } | 66 | } |
80 | 67 | ||
81 | Ticket *Resource::requestSaveTicket() | 68 | Ticket *Resource::requestSaveTicket() |
82 | { | 69 | { |
83 | return 0; | 70 | return 0; |
84 | } | 71 | } |
85 | 72 | ||
86 | bool Resource::load() | 73 | bool Resource::load() |
87 | { | 74 | { |
88 | return true; | 75 | return true; |
89 | } | 76 | } |
90 | 77 | ||
91 | bool Resource::save( Ticket * ) | 78 | bool Resource::save( Ticket * ) |
92 | { | 79 | { |
93 | return false; | 80 | return false; |
94 | } | 81 | } |
95 | 82 | ||
96 | Ticket *Resource::createTicket( Resource *resource ) | 83 | Ticket *Resource::createTicket( Resource *resource ) |
97 | { | 84 | { |
98 | return new Ticket( resource ); | 85 | return new Ticket( resource ); |
99 | } | 86 | } |
100 | 87 | ||
101 | void Resource::removeAddressee( const Addressee& ) | 88 | void Resource::removeAddressee( const Addressee& ) |
102 | { | 89 | { |
103 | // do nothing | 90 | // do nothing |
104 | } | 91 | } |
105 | 92 | ||
106 | void Resource::cleanUp() | 93 | void Resource::cleanUp() |
107 | { | 94 | { |
108 | // do nothing | 95 | // do nothing |
109 | } | 96 | } |
110 | 97 | ||
111 | bool Resource::isSyncable() const | ||
112 | { | ||
113 | return (mSyncProfile != 0); | ||
114 | } | ||
115 | |||
116 | KSyncProfile* Resource::getSyncProfile() | ||
117 | { | ||
118 | return mSyncProfile; | ||
119 | } | ||
120 | |||
121 | |||
122 | QString Resource::fileName() const | 98 | QString Resource::fileName() const |
123 | { | 99 | { |
124 | return mFileName; | 100 | return mFileName; |
125 | } | 101 | } |
126 | 102 | ||
127 | void Resource::setFileName( const QString &fileName ) | 103 | void Resource::setFileName( const QString &fileName ) |
128 | { | 104 | { |
129 | mFileName = fileName; | 105 | mFileName = fileName; |
130 | } | 106 | } |
131 | 107 | ||
132 | /** | 108 | /** |
133 | * Set the name of resource.You can override this method, | 109 | * Set the name of resource.You can override this method, |
134 | * but also remember to call Resource::setResourceName(). | 110 | * but also remember to call Resource::setResourceName(). |
135 | */ | 111 | */ |
136 | void Resource::setResourceName( const QString &name ) | 112 | void Resource::setResourceName( const QString &name ) |
137 | { | 113 | { |
138 | KRES::Resource::setResourceName(name); | 114 | KRES::Resource::setResourceName(name); |
139 | if(mSyncProfile != 0) { | ||
140 | mSyncProfile->setName( name ); | ||
141 | } | ||
142 | |||
143 | } | 115 | } |
144 | 116 | ||
diff --git a/kabc/resource.h b/kabc/resource.h index 2024d2d..e5f0d5d 100644 --- a/kabc/resource.h +++ b/kabc/resource.h | |||
@@ -1,171 +1,157 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_RESOURCE_H | 28 | #ifndef KABC_RESOURCE_H |
29 | #define KABC_RESOURCE_H | 29 | #define KABC_RESOURCE_H |
30 | 30 | ||
31 | #include <kresources/resource.h> | 31 | #include <kresources/resource.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include "addressbook.h" | 34 | #include "addressbook.h" |
35 | 35 | ||
36 | class KSyncProfile; | ||
37 | |||
38 | namespace KABC { | 36 | namespace KABC { |
39 | 37 | ||
40 | /** | 38 | /** |
41 | * @short Helper class for handling coordinated save of address books. | 39 | * @short Helper class for handling coordinated save of address books. |
42 | * | 40 | * |
43 | * This class is used as helper class for saving address book. | 41 | * This class is used as helper class for saving address book. |
44 | * @see requestSaveTicket(), save(). | 42 | * @see requestSaveTicket(), save(). |
45 | */ | 43 | */ |
46 | class Ticket | 44 | class Ticket |
47 | { | 45 | { |
48 | friend class Resource; | 46 | friend class Resource; |
49 | public: | 47 | public: |
50 | Resource *resource() { return mResource; } | 48 | Resource *resource() { return mResource; } |
51 | 49 | ||
52 | private: | 50 | private: |
53 | Ticket( Resource *resource ) : mResource( resource ) {} | 51 | Ticket( Resource *resource ) : mResource( resource ) {} |
54 | 52 | ||
55 | Resource *mResource; | 53 | Resource *mResource; |
56 | }; | 54 | }; |
57 | 55 | ||
58 | /** | 56 | /** |
59 | * @internal | 57 | * @internal |
60 | */ | 58 | */ |
61 | class Resource : public KRES::Resource | 59 | class Resource : public KRES::Resource |
62 | { | 60 | { |
63 | private: | ||
64 | /** | ||
65 | * make this constructor private to force everybody to use the other one | ||
66 | */ | ||
67 | Resource( const KConfig *config); | ||
68 | |||
69 | public: | 61 | public: |
70 | /** | 62 | /** |
71 | * Constructor | 63 | * Constructor |
72 | */ | 64 | */ |
73 | Resource( const KConfig *config, bool syncable ); | 65 | Resource( const KConfig *config ); |
74 | 66 | ||
75 | /** | 67 | /** |
76 | * Destructor. | 68 | * Destructor. |
77 | */ | 69 | */ |
78 | virtual ~Resource(); | 70 | virtual ~Resource(); |
79 | 71 | ||
80 | /** | 72 | /** |
81 | * Sets the address book of the resource. | 73 | * Sets the address book of the resource. |
82 | */ | 74 | */ |
83 | void setAddressBook( AddressBook* ); | 75 | void setAddressBook( AddressBook* ); |
84 | 76 | ||
85 | /** | 77 | /** |
86 | * Returns a pointer to the addressbook. | 78 | * Returns a pointer to the addressbook. |
87 | */ | 79 | */ |
88 | AddressBook *addressBook(); | 80 | AddressBook *addressBook(); |
89 | 81 | ||
90 | /** | 82 | /** |
91 | * Writes the resource specific config to file. | 83 | * Writes the resource specific config to file. |
92 | */ | 84 | */ |
93 | virtual void writeConfig( KConfig *config ); | 85 | virtual void writeConfig( KConfig *config ); |
94 | 86 | ||
95 | /** | 87 | /** |
96 | * Open the resource and returns if it was successfully | 88 | * Open the resource and returns if it was successfully |
97 | */ | 89 | */ |
98 | virtual bool doOpen(); | 90 | virtual bool doOpen(); |
99 | 91 | ||
100 | 92 | ||
101 | /** | 93 | /** |
102 | * Request a ticket, you have to pass through @ref save() to | 94 | * Request a ticket, you have to pass through @ref save() to |
103 | * allow locking. | 95 | * allow locking. |
104 | */ | 96 | */ |
105 | virtual Ticket *requestSaveTicket(); | 97 | virtual Ticket *requestSaveTicket(); |
106 | 98 | ||
107 | /** | 99 | /** |
108 | * Load all addressees to the addressbook | 100 | * Load all addressees to the addressbook |
109 | */ | 101 | */ |
110 | virtual bool load(); | 102 | virtual bool load(); |
111 | 103 | ||
112 | /** | 104 | /** |
113 | * Save all addressees to the addressbook. | 105 | * Save all addressees to the addressbook. |
114 | * | 106 | * |
115 | * @param ticket The ticket you get by @ref requestSaveTicket() | 107 | * @param ticket The ticket you get by @ref requestSaveTicket() |
116 | */ | 108 | */ |
117 | virtual bool save( Ticket *ticket ); | 109 | virtual bool save( Ticket *ticket ); |
118 | 110 | ||
119 | /** | 111 | /** |
120 | * Removes a addressee from resource. This method is mainly | 112 | * Removes a addressee from resource. This method is mainly |
121 | * used by record-based resources like LDAP or SQL. | 113 | * used by record-based resources like LDAP or SQL. |
122 | */ | 114 | */ |
123 | virtual void removeAddressee( const Addressee& addr ); | 115 | virtual void removeAddressee( const Addressee& addr ); |
124 | 116 | ||
125 | 117 | ||
126 | /** | 118 | /** |
127 | * This method is called by an error handler if the application | 119 | * This method is called by an error handler if the application |
128 | * crashed | 120 | * crashed |
129 | */ | 121 | */ |
130 | virtual void cleanUp(); | 122 | virtual void cleanUp(); |
131 | 123 | ||
132 | /** | 124 | /** |
133 | * Set name of file to be used for saving. | 125 | * Set name of file to be used for saving. |
134 | */ | 126 | */ |
135 | virtual void setFileName( const QString & ); | 127 | virtual void setFileName( const QString & ); |
136 | 128 | ||
137 | /** | 129 | /** |
138 | * Return name of file used for loading and saving the address book. | 130 | * Return name of file used for loading and saving the address book. |
139 | */ | 131 | */ |
140 | virtual QString fileName() const; | 132 | virtual QString fileName() const; |
141 | 133 | ||
142 | |||
143 | virtual bool isSyncable() const; | ||
144 | |||
145 | virtual KSyncProfile* getSyncProfile(); | ||
146 | |||
147 | /** | 134 | /** |
148 | * Set the name of resource.You can override this method, | 135 | * Set the name of resource.You can override this method, |
149 | * but also remember to call Resource::setResourceName(). | 136 | * but also remember to call Resource::setResourceName(). |
150 | */ | 137 | */ |
151 | virtual void setResourceName( const QString &name ); | 138 | virtual void setResourceName( const QString &name ); |
152 | 139 | ||
153 | 140 | ||
154 | 141 | ||
155 | protected: | 142 | protected: |
156 | Ticket *createTicket( Resource * ); | 143 | Ticket *createTicket( Resource * ); |
157 | virtual void doClose(); | 144 | virtual void doClose(); |
158 | 145 | ||
159 | private: | 146 | private: |
160 | AddressBook *mAddressBook; | 147 | AddressBook *mAddressBook; |
161 | KSyncProfile *mSyncProfile; | ||
162 | QString mFileName; | 148 | QString mFileName; |
163 | 149 | ||
164 | }; | 150 | }; |
165 | 151 | ||
166 | 152 | ||
167 | } | 153 | } |
168 | 154 | ||
169 | 155 | ||
170 | 156 | ||
171 | #endif | 157 | #endif |