summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp5
-rw-r--r--kaddressbook/kabcore.cpp29
-rw-r--r--kaddressbook/kabcore.h7
3 files changed, 34 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 17b9ba2..adb451f 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -209,98 +209,101 @@ bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
210} 210}
211 211
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 213{
214 return ( d->mIt != it.d->mIt ); 214 return ( d->mIt != it.d->mIt );
215} 215}
216 216
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false; 237 blockLSEchange = false;
238 d = new AddressBookData; 238 d = new AddressBookData;
239 QString fami = family; 239 QString fami = family;
240 qDebug("new ab "); 240 qDebug("new ab ");
241 if (config != 0) { 241 if (config != 0) {
242 qDebug("config != 0 "); 242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 243 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 244 qDebug("creating sync config ");
245 fami = "contact"; 245 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 247 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 248 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 249 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 250 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileName", config ); 251 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") ); 252 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 253 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 254 con->writeEntry( "ResourceName", QString("sync_res") );
255 if ( config.right(4) == ".xml" ) 255 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") ); 256 con->writeEntry( "ResourceType", QString("qtopia") );
257 else 257 else if ( config == "sharp" ) {
258 con->writeEntry( "ResourceType", QString("sharp") );
259 } else {
258 con->writeEntry( "ResourceType", QString("file") ); 260 con->writeEntry( "ResourceType", QString("file") );
261 }
259 //con->sync(); 262 //con->sync();
260 d->mConfig = con; 263 d->mConfig = con;
261 } 264 }
262 else 265 else
263 d->mConfig = new KConfig( locateLocal("config", config) ); 266 d->mConfig = new KConfig( locateLocal("config", config) );
264// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 267// qDebug("AddressBook::init 1 config=%s",config.latin1() );
265 } 268 }
266 else { 269 else {
267 d->mConfig = 0; 270 d->mConfig = 0;
268// qDebug("AddressBook::init 1 config=0"); 271// qDebug("AddressBook::init 1 config=0");
269 } 272 }
270 273
271//US d->mErrorHandler = 0; 274//US d->mErrorHandler = 0;
272 d->mManager = new KRES::Manager<Resource>( fami, false ); 275 d->mManager = new KRES::Manager<Resource>( fami, false );
273 d->mManager->readConfig( d->mConfig ); 276 d->mManager->readConfig( d->mConfig );
274 if ( family == "syncContact" ) { 277 if ( family == "syncContact" ) {
275 KRES::Manager<Resource> *manager = d->mManager; 278 KRES::Manager<Resource> *manager = d->mManager;
276 KRES::Manager<Resource>::ActiveIterator it; 279 KRES::Manager<Resource>::ActiveIterator it;
277 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 280 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
278 (*it)->setAddressBook( this ); 281 (*it)->setAddressBook( this );
279 if ( !(*it)->open() ) 282 if ( !(*it)->open() )
280 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 283 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
281 } 284 }
282 Resource *res = standardResource(); 285 Resource *res = standardResource();
283 if ( !res ) { 286 if ( !res ) {
284 qDebug("ERROR: no standard resource"); 287 qDebug("ERROR: no standard resource");
285 res = manager->createResource( "file" ); 288 res = manager->createResource( "file" );
286 if ( res ) 289 if ( res )
287 { 290 {
288 addResource( res ); 291 addResource( res );
289 } 292 }
290 else 293 else
291 qDebug(" No resource available!!!"); 294 qDebug(" No resource available!!!");
292 } 295 }
293 setStandardResource( res ); 296 setStandardResource( res );
294 manager->writeConfig(); 297 manager->writeConfig();
295 } 298 }
296 addCustomField( i18n( "Department" ), KABC::Field::Organization, 299 addCustomField( i18n( "Department" ), KABC::Field::Organization,
297 "X-Department", "KADDRESSBOOK" ); 300 "X-Department", "KADDRESSBOOK" );
298 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 301 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
299 "X-Profession", "KADDRESSBOOK" ); 302 "X-Profession", "KADDRESSBOOK" );
300 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 303 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
301 "X-AssistantsName", "KADDRESSBOOK" ); 304 "X-AssistantsName", "KADDRESSBOOK" );
302 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 305 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
303 "X-ManagersName", "KADDRESSBOOK" ); 306 "X-ManagersName", "KADDRESSBOOK" );
304 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 307 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
305 "X-SpousesName", "KADDRESSBOOK" ); 308 "X-SpousesName", "KADDRESSBOOK" );
306 addCustomField( i18n( "Office" ), KABC::Field::Personal, 309 addCustomField( i18n( "Office" ), KABC::Field::Personal,
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f8683e7..c1ead9d 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2981,64 +2981,87 @@ bool KABCore::syncAB(QString filename, int mode)
2981 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2981 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2982 } 2982 }
2983 } 2983 }
2984 } 2984 }
2985 setModified(); 2985 setModified();
2986 2986
2987 } 2987 }
2988 if ( syncOK ) 2988 if ( syncOK )
2989 mViewManager->refreshView(); 2989 mViewManager->refreshView();
2990 return syncOK; 2990 return syncOK;
2991#if 0 2991#if 0
2992 2992
2993 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2993 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2994 getEventViewerDialog()->setSyncMode( true ); 2994 getEventViewerDialog()->setSyncMode( true );
2995 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2995 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2996 getEventViewerDialog()->setSyncMode( false ); 2996 getEventViewerDialog()->setSyncMode( false );
2997 if ( syncOK ) { 2997 if ( syncOK ) {
2998 if ( KOPrefs::instance()->mWriteBackFile ) 2998 if ( KOPrefs::instance()->mWriteBackFile )
2999 { 2999 {
3000 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3000 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3001 storage->save(); 3001 storage->save();
3002 } 3002 }
3003 } 3003 }
3004 setModified(); 3004 setModified();
3005 } 3005 }
3006 3006
3007#endif 3007#endif
3008} 3008}
3009 3009
3010void KABCore::confSync() 3010void KABCore::confSync()
3011{ 3011{
3012 static KSyncPrefsDialog* sp = 0; 3012 static KSyncPrefsDialog* sp = 0;
3013 if ( ! sp ) { 3013 if ( ! sp ) {
3014 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 3014 sp = new KSyncPrefsDialog( this, "syncprefs", true );
3015 } 3015 }
3016 sp->usrReadConfig(); 3016 sp->usrReadConfig();
3017#ifndef DESKTOP_VERSION 3017#ifndef DESKTOP_VERSION
3018 sp->showMaximized(); 3018 sp->showMaximized();
3019#else 3019#else
3020 sp->show(); 3020 sp->show();
3021#endif 3021#endif
3022 sp->exec(); 3022 sp->exec();
3023 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 3023 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
3024 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 3024 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
3025 fillSyncMenu(); 3025 fillSyncMenu();
3026} 3026}
3027void KABCore::syncSharp() 3027void KABCore::syncSharp()
3028{ 3028{
3029 if ( ! syncExternal("sharp") )
3030 qDebug("ERROR sync sharp ");;
3031}
3032bool KABCore::syncExternal(QString resource)
3033{
3029 if ( mModified ) 3034 if ( mModified )
3030 save(); 3035 save();
3031 qDebug("pending syncSharp() "); 3036 if ( KABPrefs::instance()->mAskForPreferences )
3032 //mView->syncSharp(); 3037 edit_sync_options();
3033 setModified(); 3038 qDebug("syncSharp() ");
3039 AddressBook abLocal( resource,"syncContact");
3040 bool syncOK = false;
3041 if ( abLocal.load() ) {
3042 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3043 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3044 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
3045 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
3046 if ( syncOK ) {
3047 if ( KABPrefs::instance()->mWriteBackFile ) {
3048 abLocal.saveAB();
3049 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
3050 }
3051 }
3052 setModified();
3053 }
3054 if ( syncOK )
3055 mViewManager->refreshView();
3056 return syncOK;
3034 3057
3035} 3058}
3036void KABCore::syncPhone() 3059void KABCore::syncPhone()
3037{ 3060{
3038 if ( mModified ) 3061 if ( mModified )
3039 save(); 3062 save();
3040 qDebug("pending syncPhone(); "); 3063 qDebug("pending syncPhone(); ");
3041 //mView->syncPhone(); 3064 //mView->syncPhone();
3042 setModified(); 3065 setModified();
3043 3066
3044} 3067}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index f01f306..e89bf41 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -415,70 +415,71 @@ class KABCore : public QWidget
415 KAction *mActionDelete; 415 KAction *mActionDelete;
416 416
417 //US settings menu 417 //US settings menu
418 KAction *mActionConfigResources; 418 KAction *mActionConfigResources;
419 KAction *mActionConfigKAddressbook; 419 KAction *mActionConfigKAddressbook;
420 KAction *mActionConfigShortcuts; 420 KAction *mActionConfigShortcuts;
421 KAction *mActionConfigureToolbars; 421 KAction *mActionConfigureToolbars;
422 KAction *mActionKeyBindings; 422 KAction *mActionKeyBindings;
423 KToggleAction *mActionJumpBar; 423 KToggleAction *mActionJumpBar;
424 KToggleAction *mActionDetails; 424 KToggleAction *mActionDetails;
425 KAction *mActionWhoAmI; 425 KAction *mActionWhoAmI;
426 KAction *mActionCategories; 426 KAction *mActionCategories;
427 KAction *mActionAboutKAddressbook; 427 KAction *mActionAboutKAddressbook;
428 KAction *mActionLicence; 428 KAction *mActionLicence;
429 KAction *mActionFaq; 429 KAction *mActionFaq;
430 430
431 KAction *mActionDeleteView; 431 KAction *mActionDeleteView;
432 432
433 QPopupMenu *viewMenu; 433 QPopupMenu *viewMenu;
434 QPopupMenu *filterMenu; 434 QPopupMenu *filterMenu;
435 QPopupMenu *settingsMenu; 435 QPopupMenu *settingsMenu;
436 QPopupMenu *changeMenu; 436 QPopupMenu *changeMenu;
437//US QAction *mActionSave; 437//US QAction *mActionSave;
438 QPopupMenu *ImportMenu; 438 QPopupMenu *ImportMenu;
439 QPopupMenu *ExportMenu; 439 QPopupMenu *ExportMenu;
440 //LR additional methods 440 //LR additional methods
441 KAction *mActionRemoveVoice; 441 KAction *mActionRemoveVoice;
442 KAction * mActionImportOL; 442 KAction * mActionImportOL;
443 443
444#ifndef KAB_EMBEDDED 444#ifndef KAB_EMBEDDED
445 KAddressBookService *mAddressBookService; 445 KAddressBookService *mAddressBookService;
446#endif //KAB_EMBEDDED 446#endif //KAB_EMBEDDED
447 447
448 class KABCorePrivate; 448 class KABCorePrivate;
449 KABCorePrivate *d; 449 KABCorePrivate *d;
450 bool mBlockSaveFlag; 450 bool mBlockSaveFlag;
451 451
452#ifdef KAB_EMBEDDED 452#ifdef KAB_EMBEDDED
453 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 453 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
454#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
455 // LR ******************************* 455 // LR *******************************
456 // sync stuff! 456 // sync stuff!
457 QPopupMenu *syncMenu; 457 QPopupMenu *syncMenu;
458 void fillSyncMenu(); 458 void fillSyncMenu();
459 QString mCurrentSyncDevice; 459 QString mCurrentSyncDevice;
460 QString mCurrentSyncName; 460 QString mCurrentSyncName;
461 void quickSyncLocalFile(); 461 void quickSyncLocalFile();
462 bool syncWithFile( QString fn , bool quick ); 462 bool syncWithFile( QString fn , bool quick );
463 void KABCore::syncLocalFile(); 463 void syncLocalFile();
464 void KABCore::syncPhone(); 464 void syncPhone();
465 void KABCore::syncSharp(); 465 void syncSharp();
466 bool syncExternal(QString);
466 void multiSync( bool askforPrefs ); 467 void multiSync( bool askforPrefs );
467 int mCurrentSyncProfile ; 468 int mCurrentSyncProfile ;
468 void syncRemote( KSyncProfile* prof, bool ask = true); 469 void syncRemote( KSyncProfile* prof, bool ask = true);
469 void edit_sync_options(); 470 void edit_sync_options();
470 bool syncAB(QString filename, int mode); 471 bool syncAB(QString filename, int mode);
471 int ringSync(); 472 int ringSync();
472 QString getPassword( ); 473 QString getPassword( );
473 int mGlobalSyncMode; 474 int mGlobalSyncMode;
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 475 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 KABC::Addressee getLastSyncAddressee(); 476 KABC::Addressee getLastSyncAddressee();
476 QDateTime mLastAddressbookSync; 477 QDateTime mLastAddressbookSync;
477 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 478 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
478 public slots: 479 public slots:
479 void confSync(); 480 void confSync();
480 // ********************* 481 // *********************
481 482
482}; 483};
483 484
484#endif 485#endif