-rw-r--r-- | kaddressbook/kabcore.cpp | 95 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 5 |
2 files changed, 86 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 49c3b19..e912941 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -139,24 +139,25 @@ $Id$ | |||
139 | #include "extensionmanager.h" | 139 | #include "extensionmanager.h" |
140 | #include "addresseeconfig.h" | 140 | #include "addresseeconfig.h" |
141 | #include <kcmultidialog.h> | 141 | #include <kcmultidialog.h> |
142 | 142 | ||
143 | #ifdef _WIN32_ | 143 | #ifdef _WIN32_ |
144 | 144 | ||
145 | #include "kaimportoldialog.h" | 145 | #include "kaimportoldialog.h" |
146 | #else | 146 | #else |
147 | #include <unistd.h> | 147 | #include <unistd.h> |
148 | #endif | 148 | #endif |
149 | // sync includes | 149 | // sync includes |
150 | #include <libkdepim/ksyncprofile.h> | 150 | #include <libkdepim/ksyncprofile.h> |
151 | #include <libkdepim/ksyncprefsdialog.h> | ||
151 | 152 | ||
152 | 153 | ||
153 | bool pasteWithNewUid = true; | 154 | bool pasteWithNewUid = true; |
154 | 155 | ||
155 | #ifdef KAB_EMBEDDED | 156 | #ifdef KAB_EMBEDDED |
156 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 157 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
157 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 158 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
158 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 159 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
159 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 160 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
160 | #else //KAB_EMBEDDED | 161 | #else //KAB_EMBEDDED |
161 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 162 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
162 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 163 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
@@ -170,24 +171,26 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
170 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 171 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
171 | 172 | ||
172 | mAddressBook = KABC::StdAddressBook::self(); | 173 | mAddressBook = KABC::StdAddressBook::self(); |
173 | KABC::StdAddressBook::setAutomaticSave( false ); | 174 | KABC::StdAddressBook::setAutomaticSave( false ); |
174 | 175 | ||
175 | #ifndef KAB_EMBEDDED | 176 | #ifndef KAB_EMBEDDED |
176 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 177 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
177 | #endif //KAB_EMBEDDED | 178 | #endif //KAB_EMBEDDED |
178 | 179 | ||
179 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 180 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
180 | SLOT( addressBookChanged() ) ); | 181 | SLOT( addressBookChanged() ) ); |
181 | 182 | ||
183 | #if 0 | ||
184 | // LP moved to addressbook init method | ||
182 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 185 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
183 | "X-Department", "KADDRESSBOOK" ); | 186 | "X-Department", "KADDRESSBOOK" ); |
184 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 187 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
185 | "X-Profession", "KADDRESSBOOK" ); | 188 | "X-Profession", "KADDRESSBOOK" ); |
186 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 189 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
187 | "X-AssistantsName", "KADDRESSBOOK" ); | 190 | "X-AssistantsName", "KADDRESSBOOK" ); |
188 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 191 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
189 | "X-ManagersName", "KADDRESSBOOK" ); | 192 | "X-ManagersName", "KADDRESSBOOK" ); |
190 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 193 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
191 | "X-SpousesName", "KADDRESSBOOK" ); | 194 | "X-SpousesName", "KADDRESSBOOK" ); |
192 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 195 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
193 | "X-Office", "KADDRESSBOOK" ); | 196 | "X-Office", "KADDRESSBOOK" ); |
@@ -195,25 +198,25 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
195 | "X-IMAddress", "KADDRESSBOOK" ); | 198 | "X-IMAddress", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 199 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
197 | "X-Anniversary", "KADDRESSBOOK" ); | 200 | "X-Anniversary", "KADDRESSBOOK" ); |
198 | 201 | ||
199 | //US added this field to become compatible with Opie/qtopia addressbook | 202 | //US added this field to become compatible with Opie/qtopia addressbook |
200 | // values can be "female" or "male" or "". An empty field represents undefined. | 203 | // values can be "female" or "male" or "". An empty field represents undefined. |
201 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 204 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
202 | "X-Gender", "KADDRESSBOOK" ); | 205 | "X-Gender", "KADDRESSBOOK" ); |
203 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 206 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
204 | "X-Children", "KADDRESSBOOK" ); | 207 | "X-Children", "KADDRESSBOOK" ); |
205 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 208 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
206 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 209 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
207 | 210 | #endif | |
208 | initGUI(); | 211 | initGUI(); |
209 | 212 | ||
210 | mIncSearchWidget->setFocus(); | 213 | mIncSearchWidget->setFocus(); |
211 | 214 | ||
212 | 215 | ||
213 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 216 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
214 | SLOT( setContactSelected( const QString& ) ) ); | 217 | SLOT( setContactSelected( const QString& ) ) ); |
215 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 218 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
216 | SLOT( executeContact( const QString& ) ) ); | 219 | SLOT( executeContact( const QString& ) ) ); |
217 | 220 | ||
218 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 221 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
219 | SLOT( deleteContacts( ) ) ); | 222 | SLOT( deleteContacts( ) ) ); |
@@ -2186,26 +2189,26 @@ void KABCore::slotSyncMenu( int action ) | |||
2186 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2189 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2187 | if ( action == 1000 ) { | 2190 | if ( action == 1000 ) { |
2188 | syncSharp(); | 2191 | syncSharp(); |
2189 | 2192 | ||
2190 | } else if ( action == 1001 ) { | 2193 | } else if ( action == 1001 ) { |
2191 | syncLocalFile(); | 2194 | syncLocalFile(); |
2192 | 2195 | ||
2193 | } else if ( action == 1002 ) { | 2196 | } else if ( action == 1002 ) { |
2194 | quickSyncLocalFile(); | 2197 | quickSyncLocalFile(); |
2195 | 2198 | ||
2196 | } else if ( action >= 1003 ) { | 2199 | } else if ( action >= 1003 ) { |
2197 | if ( temp->getIsLocalFileSync() ) { | 2200 | if ( temp->getIsLocalFileSync() ) { |
2198 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 2201 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2199 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 2202 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2200 | } else { | 2203 | } else { |
2201 | if ( temp->getIsPhoneSync() ) { | 2204 | if ( temp->getIsPhoneSync() ) { |
2202 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2205 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2203 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2206 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2204 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2207 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2205 | syncPhone(); | 2208 | syncPhone(); |
2206 | } else | 2209 | } else |
2207 | syncRemote( temp ); | 2210 | syncRemote( temp ); |
2208 | 2211 | ||
2209 | } | 2212 | } |
2210 | } | 2213 | } |
2211 | delete temp; | 2214 | delete temp; |
@@ -2308,42 +2311,42 @@ int KABCore::ringSync() | |||
2308 | { | 2311 | { |
2309 | int syncedProfiles = 0; | 2312 | int syncedProfiles = 0; |
2310 | int i; | 2313 | int i; |
2311 | QTime timer; | 2314 | QTime timer; |
2312 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2315 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2313 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2316 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2314 | KSyncProfile* temp = new KSyncProfile (); | 2317 | KSyncProfile* temp = new KSyncProfile (); |
2315 | KABPrefs::instance()->mAskForPreferences = false; | 2318 | KABPrefs::instance()->mAskForPreferences = false; |
2316 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2319 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2317 | mCurrentSyncProfile = i; | 2320 | mCurrentSyncProfile = i; |
2318 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2321 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2319 | temp->readConfig(&config); | 2322 | temp->readConfig(&config); |
2320 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 2323 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2321 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2324 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2322 | ++syncedProfiles; | 2325 | ++syncedProfiles; |
2323 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2326 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2324 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2327 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2325 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2328 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2326 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2329 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2327 | if ( temp->getWriteBackFuture() ) | 2330 | if ( temp->getWriteBackFuture() ) |
2328 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2331 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2329 | KABPrefs::instance()->mShowSyncSummary = false; | 2332 | KABPrefs::instance()->mShowSyncSummary = false; |
2330 | mCurrentSyncDevice = syncProfileNames[i] ; | 2333 | mCurrentSyncDevice = syncProfileNames[i] ; |
2331 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2334 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2332 | if ( i == 0 ) { | 2335 | if ( i == 0 ) { |
2333 | syncSharp(); | 2336 | syncSharp(); |
2334 | } else { | 2337 | } else { |
2335 | if ( temp->getIsLocalFileSync() ) { | 2338 | if ( temp->getIsLocalFileSync() ) { |
2336 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 2339 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2337 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 2340 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2338 | } else { | 2341 | } else { |
2339 | if ( temp->getIsPhoneSync() ) { | 2342 | if ( temp->getIsPhoneSync() ) { |
2340 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2343 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2341 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2344 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2342 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2345 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2343 | syncPhone(); | 2346 | syncPhone(); |
2344 | } else | 2347 | } else |
2345 | syncRemote( temp, false ); | 2348 | syncRemote( temp, false ); |
2346 | 2349 | ||
2347 | } | 2350 | } |
2348 | } | 2351 | } |
2349 | timer.start(); | 2352 | timer.start(); |
@@ -2364,25 +2367,25 @@ int KABCore::ringSync() | |||
2364 | 2367 | ||
2365 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2368 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2366 | { | 2369 | { |
2367 | QString question; | 2370 | QString question; |
2368 | if ( ask ) { | 2371 | if ( ask ) { |
2369 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2372 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2370 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2373 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2371 | question, | 2374 | question, |
2372 | i18n("Yes"), i18n("No"), | 2375 | i18n("Yes"), i18n("No"), |
2373 | 0, 0 ) != 0 ) | 2376 | 0, 0 ) != 0 ) |
2374 | return; | 2377 | return; |
2375 | } | 2378 | } |
2376 | QString command = prof->getPreSyncCommand(); | 2379 | QString command = prof->getPreSyncCommandAB(); |
2377 | int fi; | 2380 | int fi; |
2378 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2381 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2379 | QString pwd = getPassword(); | 2382 | QString pwd = getPassword(); |
2380 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2383 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2381 | 2384 | ||
2382 | } | 2385 | } |
2383 | int maxlen = 30; | 2386 | int maxlen = 30; |
2384 | if ( QApplication::desktop()->width() > 320 ) | 2387 | if ( QApplication::desktop()->width() > 320 ) |
2385 | maxlen += 25; | 2388 | maxlen += 25; |
2386 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2389 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2387 | int fileSize = 0; | 2390 | int fileSize = 0; |
2388 | int result = system ( command ); | 2391 | int result = system ( command ); |
@@ -2396,31 +2399,31 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask) | |||
2396 | command.insert( len , "\n" ); | 2399 | command.insert( len , "\n" ); |
2397 | len += maxlen +2; | 2400 | len += maxlen +2; |
2398 | } | 2401 | } |
2399 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2402 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2400 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2403 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2401 | question, | 2404 | question, |
2402 | i18n("Okay!")) ; | 2405 | i18n("Okay!")) ; |
2403 | setCaption ("KO/Pi"); | 2406 | setCaption ("KO/Pi"); |
2404 | return; | 2407 | return; |
2405 | } | 2408 | } |
2406 | setCaption ( i18n( "Copying succeed." ) ); | 2409 | setCaption ( i18n( "Copying succeed." ) ); |
2407 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2410 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2408 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 2411 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2409 | // Event* e = mView->getLastSyncEvent(); | 2412 | // Event* e = mView->getLastSyncEvent(); |
2410 | // e->setReadOnly( false ); | 2413 | // e->setReadOnly( false ); |
2411 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2414 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2412 | // e->setReadOnly( true ); | 2415 | // e->setReadOnly( true ); |
2413 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2416 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2414 | command = prof->getPostSyncCommand(); | 2417 | command = prof->getPostSyncCommandAB(); |
2415 | int fi; | 2418 | int fi; |
2416 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2419 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2417 | QString pwd = getPassword(); | 2420 | QString pwd = getPassword(); |
2418 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2421 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2419 | 2422 | ||
2420 | } | 2423 | } |
2421 | setCaption ( i18n( "Writing back file ..." ) ); | 2424 | setCaption ( i18n( "Writing back file ..." ) ); |
2422 | result = system ( command ); | 2425 | result = system ( command ); |
2423 | qDebug("KO: Writing back file result: %d ", result); | 2426 | qDebug("KO: Writing back file result: %d ", result); |
2424 | if ( result != 0 ) { | 2427 | if ( result != 0 ) { |
2425 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2428 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2426 | return; | 2429 | return; |
@@ -2501,43 +2504,109 @@ QString KABCore::getPassword( ) | |||
2501 | QPushButton pb ( "OK", &dia); | 2504 | QPushButton pb ( "OK", &dia); |
2502 | lay.addWidget( &pb ); | 2505 | lay.addWidget( &pb ); |
2503 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2504 | dia.show(); | 2507 | dia.show(); |
2505 | int res = dia.exec(); | 2508 | int res = dia.exec(); |
2506 | if ( res ) | 2509 | if ( res ) |
2507 | retfile = lab.text(); | 2510 | retfile = lab.text(); |
2508 | dia.hide(); | 2511 | dia.hide(); |
2509 | qApp->processEvents(); | 2512 | qApp->processEvents(); |
2510 | return retfile; | 2513 | return retfile; |
2511 | 2514 | ||
2512 | } | 2515 | } |
2516 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | ||
2517 | { | ||
2513 | 2518 | ||
2519 | } | ||
2514 | bool KABCore::syncAB(QString filename, int mode) | 2520 | bool KABCore::syncAB(QString filename, int mode) |
2515 | { | 2521 | { |
2516 | 2522 | ||
2523 | |||
2524 | |||
2525 | mGlobalSyncMode = SYNC_MODE_NORMAL; | ||
2526 | AddressBook abLocal(filename,"syncContact"); | ||
2527 | bool syncOK = false; | ||
2528 | if ( abLocal.load() ) { | ||
2529 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | ||
2530 | AddressBook::Iterator it; | ||
2531 | QStringList vcards; | ||
2532 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2533 | qDebug("Name %s ", (*it).familyName().latin1()); | ||
2534 | } | ||
2535 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | ||
2536 | if ( syncOK ) { | ||
2537 | if ( KABPrefs::instance()->mWriteBackFile ) | ||
2538 | { | ||
2539 | abLocal.saveAB(); | ||
2540 | } | ||
2541 | } | ||
2542 | setModified(); | ||
2543 | |||
2544 | } | ||
2545 | if ( syncOK ) | ||
2546 | ;//updateView(); | ||
2547 | return syncOK; | ||
2548 | #if 0 | ||
2549 | mGlobalSyncMode = SYNC_MODE_NORMAL; | ||
2550 | CalendarLocal* calendar = new CalendarLocal(); | ||
2551 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | ||
2552 | FileStorage* storage = new FileStorage( calendar ); | ||
2553 | bool syncOK = false; | ||
2554 | storage->setFileName( filename ); | ||
2555 | // qDebug("loading ... "); | ||
2556 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | ||
2557 | getEventViewerDialog()->setSyncMode( true ); | ||
2558 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | ||
2559 | getEventViewerDialog()->setSyncMode( false ); | ||
2560 | if ( syncOK ) { | ||
2561 | if ( KOPrefs::instance()->mWriteBackFile ) | ||
2562 | { | ||
2563 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | ||
2564 | storage->save(); | ||
2565 | } | ||
2566 | } | ||
2567 | setModified(); | ||
2568 | } | ||
2569 | delete storage; | ||
2570 | delete calendar; | ||
2571 | if ( syncOK ) | ||
2572 | updateView(); | ||
2573 | return syncOK; | ||
2574 | #endif | ||
2517 | } | 2575 | } |
2518 | 2576 | ||
2519 | 2577 | ||
2520 | void KABCore::confSync() | 2578 | void KABCore::confSync() |
2521 | { | 2579 | { |
2522 | //mView->confSync(); | 2580 | static KSyncPrefsDialog* sp = 0; |
2523 | qDebug("pending KABCore::confSync() "); | 2581 | if ( ! sp ) { |
2582 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | ||
2583 | } | ||
2584 | sp->usrReadConfig(); | ||
2585 | #ifndef DESKTOP_VERSION | ||
2586 | sp->showMaximized(); | ||
2587 | #else | ||
2588 | sp->show(); | ||
2589 | #endif | ||
2590 | sp->exec(); | ||
2591 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | ||
2592 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | ||
2524 | fillSyncMenu(); | 2593 | fillSyncMenu(); |
2525 | } | 2594 | } |
2526 | void KABCore::syncSharp() | 2595 | void KABCore::syncSharp() |
2527 | { | 2596 | { |
2528 | if ( mModified ) | 2597 | if ( mModified ) |
2529 | save(); | 2598 | save(); |
2530 | qDebug("pending syncSharp() "); | 2599 | qDebug("pending syncSharp() "); |
2531 | //mView->syncSharp(); | 2600 | //mView->syncSharp(); |
2532 | mModified = true ; | 2601 | setModified(); |
2533 | 2602 | ||
2534 | } | 2603 | } |
2535 | void KABCore::syncPhone() | 2604 | void KABCore::syncPhone() |
2536 | { | 2605 | { |
2537 | if ( mModified ) | 2606 | if ( mModified ) |
2538 | save(); | 2607 | save(); |
2539 | qDebug("pending syncPhone(); "); | 2608 | qDebug("pending syncPhone(); "); |
2540 | //mView->syncPhone(); | 2609 | //mView->syncPhone(); |
2541 | setModified(); | 2610 | setModified(); |
2542 | 2611 | ||
2543 | } | 2612 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 10ce8f4..4487a8a 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -447,32 +447,35 @@ class KABCore : public QWidget | |||
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 | void confSync(); | ||
460 | QString mCurrentSyncDevice; | 459 | QString mCurrentSyncDevice; |
461 | QString mCurrentSyncName; | 460 | QString mCurrentSyncName; |
462 | void quickSyncLocalFile(); | 461 | void quickSyncLocalFile(); |
463 | bool syncWithFile( QString fn , bool quick ); | 462 | bool syncWithFile( QString fn , bool quick ); |
464 | void KABCore::syncLocalFile(); | 463 | void KABCore::syncLocalFile(); |
465 | void KABCore::syncPhone(); | 464 | void KABCore::syncPhone(); |
466 | void KABCore::syncSharp(); | 465 | void KABCore::syncSharp(); |
467 | void multiSync( bool askforPrefs ); | 466 | void multiSync( bool askforPrefs ); |
468 | int mCurrentSyncProfile ; | 467 | int mCurrentSyncProfile ; |
469 | void syncRemote( KSyncProfile* prof, bool ask = true); | 468 | void syncRemote( KSyncProfile* prof, bool ask = true); |
470 | void edit_sync_options(); | 469 | void edit_sync_options(); |
471 | bool syncAB(QString filename, int mode); | 470 | bool syncAB(QString filename, int mode); |
472 | int ringSync(); | 471 | int ringSync(); |
473 | QString getPassword( ); | 472 | QString getPassword( ); |
473 | int mGlobalSyncMode; | ||
474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | ||
475 | public slots: | ||
476 | void confSync(); | ||
474 | // ********************* | 477 | // ********************* |
475 | 478 | ||
476 | }; | 479 | }; |
477 | 480 | ||
478 | #endif | 481 | #endif |