-rw-r--r-- | kabc/addressbook.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 23 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 22 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 2 |
8 files changed, 61 insertions, 15 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index d101589..9b196b5 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -817,98 +817,101 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeRes | |||
817 | if ( found ) | 817 | if ( found ) |
818 | return; | 818 | return; |
819 | d->mAddressees.append( a ); | 819 | d->mAddressees.append( a ); |
820 | Addressee& addr = d->mAddressees.last(); | 820 | Addressee& addr = d->mAddressees.last(); |
821 | if ( addr.resource() == 0 ) | 821 | if ( addr.resource() == 0 ) |
822 | addr.setResource( standardResource() ); | 822 | addr.setResource( standardResource() ); |
823 | 823 | ||
824 | addr.setChanged( true ); | 824 | addr.setChanged( true ); |
825 | } | 825 | } |
826 | 826 | ||
827 | void AddressBook::removeAddressee( const Addressee &a ) | 827 | void AddressBook::removeAddressee( const Addressee &a ) |
828 | { | 828 | { |
829 | Iterator it; | 829 | Iterator it; |
830 | Iterator it2; | 830 | Iterator it2; |
831 | bool found = false; | 831 | bool found = false; |
832 | for ( it = begin(); it != end(); ++it ) { | 832 | for ( it = begin(); it != end(); ++it ) { |
833 | if ( a.uid() == (*it).uid() ) { | 833 | if ( a.uid() == (*it).uid() ) { |
834 | found = true; | 834 | found = true; |
835 | it2 = it; | 835 | it2 = it; |
836 | } else { | 836 | } else { |
837 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 837 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
838 | QString name = (*it).uid().mid( 19 ); | 838 | QString name = (*it).uid().mid( 19 ); |
839 | Addressee b = a; | 839 | Addressee b = a; |
840 | QString id = b.getID( name ); | 840 | QString id = b.getID( name ); |
841 | if ( ! id.isEmpty() ) { | 841 | if ( ! id.isEmpty() ) { |
842 | QString des = (*it).note(); | 842 | QString des = (*it).note(); |
843 | if( des.find( id ) < 0 ) { | 843 | if( des.find( id ) < 0 ) { |
844 | des += id + ","; | 844 | des += id + ","; |
845 | (*it).setNote( des ); | 845 | (*it).setNote( des ); |
846 | } | 846 | } |
847 | } | 847 | } |
848 | } | 848 | } |
849 | 849 | ||
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
853 | if ( found ) | 853 | if ( found ) |
854 | removeAddressee( it2 ); | 854 | removeAddressee( it2 ); |
855 | 855 | ||
856 | } | 856 | } |
857 | 857 | ||
858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
859 | { | 859 | { |
860 | Iterator it = begin(); | 860 | Iterator it = begin(); |
861 | Iterator it2 ; | 861 | Iterator it2 ; |
862 | QDateTime dt ( QDate( 2004,1,1) ); | 862 | QDateTime dt ( QDate( 2004,1,1) ); |
863 | while ( it != end() ) { | 863 | while ( it != end() ) { |
864 | (*it).setRevision( dt ); | 864 | (*it).setRevision( dt ); |
865 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 865 | if (( *it).IDStr() != "changed" ) { |
866 | (*it).setIDStr(""); | 866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | ||
868 | (*it).setIDStr(""); | ||
869 | } | ||
867 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
868 | it2 = it; | 871 | it2 = it; |
869 | //qDebug("removing %s ",(*it).uid().latin1() ); | 872 | //qDebug("removing %s ",(*it).uid().latin1() ); |
870 | ++it; | 873 | ++it; |
871 | removeAddressee( it2 ); | 874 | removeAddressee( it2 ); |
872 | } else { | 875 | } else { |
873 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 876 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
874 | ++it; | 877 | ++it; |
875 | } | 878 | } |
876 | } | 879 | } |
877 | deleteRemovedAddressees(); | 880 | deleteRemovedAddressees(); |
878 | } | 881 | } |
879 | 882 | ||
880 | void AddressBook::removeAddressee( const Iterator &it ) | 883 | void AddressBook::removeAddressee( const Iterator &it ) |
881 | { | 884 | { |
882 | d->mRemovedAddressees.append( (*it) ); | 885 | d->mRemovedAddressees.append( (*it) ); |
883 | d->mAddressees.remove( it.d->mIt ); | 886 | d->mAddressees.remove( it.d->mIt ); |
884 | } | 887 | } |
885 | 888 | ||
886 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 889 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
887 | { | 890 | { |
888 | Iterator it; | 891 | Iterator it; |
889 | for ( it = begin(); it != end(); ++it ) { | 892 | for ( it = begin(); it != end(); ++it ) { |
890 | if ( a.uid() == (*it).uid() ) { | 893 | if ( a.uid() == (*it).uid() ) { |
891 | return it; | 894 | return it; |
892 | } | 895 | } |
893 | } | 896 | } |
894 | return end(); | 897 | return end(); |
895 | } | 898 | } |
896 | 899 | ||
897 | Addressee AddressBook::findByUid( const QString &uid ) | 900 | Addressee AddressBook::findByUid( const QString &uid ) |
898 | { | 901 | { |
899 | Iterator it; | 902 | Iterator it; |
900 | for ( it = begin(); it != end(); ++it ) { | 903 | for ( it = begin(); it != end(); ++it ) { |
901 | if ( uid == (*it).uid() ) { | 904 | if ( uid == (*it).uid() ) { |
902 | return *it; | 905 | return *it; |
903 | } | 906 | } |
904 | } | 907 | } |
905 | return Addressee(); | 908 | return Addressee(); |
906 | } | 909 | } |
907 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 910 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
908 | { | 911 | { |
909 | //qDebug("AddressBook::preExternSync "); | 912 | //qDebug("AddressBook::preExternSync "); |
910 | AddressBook::Iterator it; | 913 | AddressBook::Iterator it; |
911 | for ( it = begin(); it != end(); ++it ) { | 914 | for ( it = begin(); it != end(); ++it ) { |
912 | (*it).setID( csd, (*it).externalUID() ); | 915 | (*it).setID( csd, (*it).externalUID() ); |
913 | (*it).computeCsum( csd ); | 916 | (*it).computeCsum( csd ); |
914 | } | 917 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 2f00a09..ea87929 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1267,100 +1267,102 @@ void KABCore::setJumpButtonBarVisible( bool visible ) | |||
1267 | else | 1267 | else |
1268 | { | 1268 | { |
1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1270 | if (mViewManager->isVisible()) | 1270 | if (mViewManager->isVisible()) |
1271 | { | 1271 | { |
1272 | if ( visible ) | 1272 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1273 | mJumpButtonBar->show(); |
1274 | else | 1274 | else |
1275 | mJumpButtonBar->hide(); | 1275 | mJumpButtonBar->hide(); |
1276 | } | 1276 | } |
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | mJumpButtonBar->hide(); | 1279 | mJumpButtonBar->hide(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | 1284 | ||
1285 | void KABCore::setDetailsToState() | 1285 | void KABCore::setDetailsToState() |
1286 | { | 1286 | { |
1287 | setDetailsVisible( mActionDetails->isChecked() ); | 1287 | setDetailsVisible( mActionDetails->isChecked() ); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void KABCore::setDetailsVisible( bool visible ) | 1292 | void KABCore::setDetailsVisible( bool visible ) |
1293 | { | 1293 | { |
1294 | if (visible && mDetails->isHidden()) | 1294 | if (visible && mDetails->isHidden()) |
1295 | { | 1295 | { |
1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1297 | if ( addrList.count() > 0 ) | 1297 | if ( addrList.count() > 0 ) |
1298 | mDetails->setAddressee( addrList[ 0 ] ); | 1298 | mDetails->setAddressee( addrList[ 0 ] ); |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1302 | // the listview and the detailview. We do that by changing the splitbar size. | 1302 | // the listview and the detailview. We do that by changing the splitbar size. |
1303 | if (mMultipleViewsAtOnce) | 1303 | if (mMultipleViewsAtOnce) |
1304 | { | 1304 | { |
1305 | if ( visible ) | 1305 | if ( visible ) |
1306 | mDetails->show(); | 1306 | mDetails->show(); |
1307 | else | 1307 | else |
1308 | mDetails->hide(); | 1308 | mDetails->hide(); |
1309 | } | 1309 | } |
1310 | else | 1310 | else |
1311 | { | 1311 | { |
1312 | if ( visible ) { | 1312 | if ( visible ) { |
1313 | mViewManager->hide(); | 1313 | mViewManager->hide(); |
1314 | mDetails->show(); | 1314 | mDetails->show(); |
1315 | mIncSearchWidget->setFocus(); | ||
1315 | } | 1316 | } |
1316 | else { | 1317 | else { |
1317 | mViewManager->show(); | 1318 | mViewManager->show(); |
1318 | mDetails->hide(); | 1319 | mDetails->hide(); |
1320 | mViewManager->setFocusAV(); | ||
1319 | } | 1321 | } |
1320 | setJumpButtonBarVisible( !visible ); | 1322 | setJumpButtonBarVisible( !visible ); |
1321 | } | 1323 | } |
1322 | 1324 | ||
1323 | } | 1325 | } |
1324 | 1326 | ||
1325 | void KABCore::extensionChanged( int id ) | 1327 | void KABCore::extensionChanged( int id ) |
1326 | { | 1328 | { |
1327 | //change the details view only for non desktop systems | 1329 | //change the details view only for non desktop systems |
1328 | #ifndef DESKTOP_VERSION | 1330 | #ifndef DESKTOP_VERSION |
1329 | 1331 | ||
1330 | if (id == 0) | 1332 | if (id == 0) |
1331 | { | 1333 | { |
1332 | //the user disabled the extension. | 1334 | //the user disabled the extension. |
1333 | 1335 | ||
1334 | if (mMultipleViewsAtOnce) | 1336 | if (mMultipleViewsAtOnce) |
1335 | { // enable detailsview again | 1337 | { // enable detailsview again |
1336 | setDetailsVisible( true ); | 1338 | setDetailsVisible( true ); |
1337 | mActionDetails->setChecked( true ); | 1339 | mActionDetails->setChecked( true ); |
1338 | } | 1340 | } |
1339 | else | 1341 | else |
1340 | { //go back to the listview | 1342 | { //go back to the listview |
1341 | setDetailsVisible( false ); | 1343 | setDetailsVisible( false ); |
1342 | mActionDetails->setChecked( false ); | 1344 | mActionDetails->setChecked( false ); |
1343 | mActionDetails->setEnabled(true); | 1345 | mActionDetails->setEnabled(true); |
1344 | } | 1346 | } |
1345 | 1347 | ||
1346 | } | 1348 | } |
1347 | else | 1349 | else |
1348 | { | 1350 | { |
1349 | //the user enabled the extension. | 1351 | //the user enabled the extension. |
1350 | setDetailsVisible( false ); | 1352 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1353 | mActionDetails->setChecked( false ); |
1352 | 1354 | ||
1353 | if (!mMultipleViewsAtOnce) | 1355 | if (!mMultipleViewsAtOnce) |
1354 | { | 1356 | { |
1355 | mActionDetails->setEnabled(false); | 1357 | mActionDetails->setEnabled(false); |
1356 | } | 1358 | } |
1357 | 1359 | ||
1358 | mExtensionManager->setSelectionChanged(); | 1360 | mExtensionManager->setSelectionChanged(); |
1359 | 1361 | ||
1360 | } | 1362 | } |
1361 | 1363 | ||
1362 | #endif// DESKTOP_VERSION | 1364 | #endif// DESKTOP_VERSION |
1363 | 1365 | ||
1364 | } | 1366 | } |
1365 | 1367 | ||
1366 | 1368 | ||
@@ -1999,96 +2001,99 @@ void KABCore::addActionsManually() | |||
1999 | mActionRemoveVoice->plug( changeMenu ); | 2001 | mActionRemoveVoice->plug( changeMenu ); |
2000 | // settings menu | 2002 | // settings menu |
2001 | //US special menuentry to configure the addressbook resources. On KDE | 2003 | //US special menuentry to configure the addressbook resources. On KDE |
2002 | // you do that through the control center !!! | 2004 | // you do that through the control center !!! |
2003 | mActionConfigResources->plug( settingsMenu ); | 2005 | mActionConfigResources->plug( settingsMenu ); |
2004 | settingsMenu->insertSeparator(); | 2006 | settingsMenu->insertSeparator(); |
2005 | 2007 | ||
2006 | mActionConfigKAddressbook->plug( settingsMenu ); | 2008 | mActionConfigKAddressbook->plug( settingsMenu ); |
2007 | 2009 | ||
2008 | if ( mIsPart ) { | 2010 | if ( mIsPart ) { |
2009 | //US not implemented yet | 2011 | //US not implemented yet |
2010 | //mActionConfigShortcuts->plug( settingsMenu ); | 2012 | //mActionConfigShortcuts->plug( settingsMenu ); |
2011 | //mActionConfigureToolbars->plug( settingsMenu ); | 2013 | //mActionConfigureToolbars->plug( settingsMenu ); |
2012 | 2014 | ||
2013 | } else { | 2015 | } else { |
2014 | //US not implemented yet | 2016 | //US not implemented yet |
2015 | //mActionKeyBindings->plug( settingsMenu ); | 2017 | //mActionKeyBindings->plug( settingsMenu ); |
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | settingsMenu->insertSeparator(); | 2020 | settingsMenu->insertSeparator(); |
2019 | 2021 | ||
2020 | mActionJumpBar->plug( settingsMenu ); | 2022 | mActionJumpBar->plug( settingsMenu ); |
2021 | mActionDetails->plug( settingsMenu ); | 2023 | mActionDetails->plug( settingsMenu ); |
2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2024 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2023 | mActionDetails->plug( tb ); | 2025 | mActionDetails->plug( tb ); |
2024 | settingsMenu->insertSeparator(); | 2026 | settingsMenu->insertSeparator(); |
2025 | mActionBR->plug(settingsMenu ); | 2027 | mActionBR->plug(settingsMenu ); |
2026 | settingsMenu->insertSeparator(); | 2028 | settingsMenu->insertSeparator(); |
2027 | 2029 | ||
2028 | mActionWhoAmI->plug( settingsMenu ); | 2030 | mActionWhoAmI->plug( settingsMenu ); |
2029 | mActionCategories->plug( settingsMenu ); | 2031 | mActionCategories->plug( settingsMenu ); |
2030 | 2032 | ||
2031 | 2033 | ||
2032 | mActionWN->plug( helpMenu ); | 2034 | mActionWN->plug( helpMenu ); |
2033 | mActionSyncHowto->plug( helpMenu ); | 2035 | mActionSyncHowto->plug( helpMenu ); |
2034 | mActionLicence->plug( helpMenu ); | 2036 | mActionLicence->plug( helpMenu ); |
2035 | mActionFaq->plug( helpMenu ); | 2037 | mActionFaq->plug( helpMenu ); |
2036 | mActionAboutKAddressbook->plug( helpMenu ); | 2038 | mActionAboutKAddressbook->plug( helpMenu ); |
2037 | 2039 | ||
2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2040 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2039 | 2041 | ||
2040 | mActionSave->plug( tb ); | 2042 | mActionSave->plug( tb ); |
2041 | mViewManager->getFilterAction()->plug ( tb); | 2043 | mViewManager->getFilterAction()->plug ( tb); |
2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2044 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2043 | mActionUndo->plug( tb ); | 2045 | mActionUndo->plug( tb ); |
2044 | mActionDelete->plug( tb ); | 2046 | mActionDelete->plug( tb ); |
2045 | mActionRedo->plug( tb ); | 2047 | mActionRedo->plug( tb ); |
2046 | } | 2048 | } |
2049 | } else { | ||
2050 | if (KABPrefs::instance()->mMultipleViewsAtOnce ) | ||
2051 | mActionSave->plug( tb ); | ||
2047 | } | 2052 | } |
2048 | //mActionQuit->plug ( tb ); | 2053 | //mActionQuit->plug ( tb ); |
2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2054 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2050 | 2055 | ||
2051 | //US link the searchwidget first to this. | 2056 | //US link the searchwidget first to this. |
2052 | // The real linkage to the toolbar happens later. | 2057 | // The real linkage to the toolbar happens later. |
2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2058 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2054 | //US tb->insertItem( mIncSearchWidget ); | 2059 | //US tb->insertItem( mIncSearchWidget ); |
2055 | /*US | 2060 | /*US |
2056 | mIncSearchWidget = new IncSearchWidget( tb ); | 2061 | mIncSearchWidget = new IncSearchWidget( tb ); |
2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2062 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2058 | SLOT( incrementalSearch( const QString& ) ) ); | 2063 | SLOT( incrementalSearch( const QString& ) ) ); |
2059 | 2064 | ||
2060 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2065 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2061 | 2066 | ||
2062 | //US topLayout->addWidget( mJumpButtonBar ); | 2067 | //US topLayout->addWidget( mJumpButtonBar ); |
2063 | this->layout()->add( mJumpButtonBar ); | 2068 | this->layout()->add( mJumpButtonBar ); |
2064 | */ | 2069 | */ |
2065 | 2070 | ||
2066 | #endif //KAB_EMBEDDED | 2071 | #endif //KAB_EMBEDDED |
2067 | 2072 | ||
2068 | mActionExport2phone->plug( ExportMenu ); | 2073 | mActionExport2phone->plug( ExportMenu ); |
2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2074 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2070 | syncManager->fillSyncMenu(); | 2075 | syncManager->fillSyncMenu(); |
2071 | 2076 | ||
2072 | } | 2077 | } |
2073 | void KABCore::showLicence() | 2078 | void KABCore::showLicence() |
2074 | { | 2079 | { |
2075 | KApplication::showLicence(); | 2080 | KApplication::showLicence(); |
2076 | } | 2081 | } |
2077 | void KABCore::removeVoice() | 2082 | void KABCore::removeVoice() |
2078 | { | 2083 | { |
2079 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2084 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2080 | return; | 2085 | return; |
2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2086 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2082 | KABC::Addressee::List::Iterator it; | 2087 | KABC::Addressee::List::Iterator it; |
2083 | for ( it = list.begin(); it != list.end(); ++it ) { | 2088 | for ( it = list.begin(); it != list.end(); ++it ) { |
2084 | 2089 | ||
2085 | if ( (*it).removeVoice() ) | 2090 | if ( (*it).removeVoice() ) |
2086 | contactModified((*it) ); | 2091 | contactModified((*it) ); |
2087 | } | 2092 | } |
2088 | } | 2093 | } |
2089 | 2094 | ||
2090 | 2095 | ||
2091 | 2096 | ||
2092 | void KABCore::clipboardDataChanged() | 2097 | void KABCore::clipboardDataChanged() |
2093 | { | 2098 | { |
2094 | 2099 | ||
@@ -2462,97 +2467,106 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2462 | localIsNew = localMod >= remoteMod; | 2467 | localIsNew = localMod >= remoteMod; |
2463 | //qDebug("conflict! ************************************** "); | 2468 | //qDebug("conflict! ************************************** "); |
2464 | { | 2469 | { |
2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2470 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2466 | result = acd.executeD(localIsNew); | 2471 | result = acd.executeD(localIsNew); |
2467 | return result; | 2472 | return result; |
2468 | } | 2473 | } |
2469 | break; | 2474 | break; |
2470 | case SYNC_PREF_FORCE_LOCAL: | 2475 | case SYNC_PREF_FORCE_LOCAL: |
2471 | return 1; | 2476 | return 1; |
2472 | break; | 2477 | break; |
2473 | case SYNC_PREF_FORCE_REMOTE: | 2478 | case SYNC_PREF_FORCE_REMOTE: |
2474 | return 2; | 2479 | return 2; |
2475 | break; | 2480 | break; |
2476 | 2481 | ||
2477 | default: | 2482 | default: |
2478 | // SYNC_PREF_TAKE_BOTH not implemented | 2483 | // SYNC_PREF_TAKE_BOTH not implemented |
2479 | break; | 2484 | break; |
2480 | } | 2485 | } |
2481 | return 0; | 2486 | return 0; |
2482 | } | 2487 | } |
2483 | 2488 | ||
2484 | 2489 | ||
2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2490 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2486 | { | 2491 | { |
2487 | bool syncOK = true; | 2492 | bool syncOK = true; |
2488 | int addedAddressee = 0; | 2493 | int addedAddressee = 0; |
2489 | int addedAddresseeR = 0; | 2494 | int addedAddresseeR = 0; |
2490 | int deletedAddresseeR = 0; | 2495 | int deletedAddresseeR = 0; |
2491 | int deletedAddresseeL = 0; | 2496 | int deletedAddresseeL = 0; |
2492 | int changedLocal = 0; | 2497 | int changedLocal = 0; |
2493 | int changedRemote = 0; | 2498 | int changedRemote = 0; |
2494 | 2499 | ||
2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2500 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2501 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2497 | 2502 | ||
2498 | //QPtrList<Addressee> el = local->rawAddressees(); | 2503 | //QPtrList<Addressee> el = local->rawAddressees(); |
2499 | Addressee addresseeR; | 2504 | Addressee addresseeR; |
2500 | QString uid; | 2505 | QString uid; |
2501 | int take; | 2506 | int take; |
2502 | Addressee addresseeL; | 2507 | Addressee addresseeL; |
2503 | Addressee addresseeRSync; | 2508 | Addressee addresseeRSync; |
2504 | Addressee addresseeLSync; | 2509 | Addressee addresseeLSync; |
2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2510 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2511 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2507 | bool fullDateRange = false; | 2512 | bool fullDateRange = false; |
2508 | local->resetTempSyncStat(); | 2513 | local->resetTempSyncStat(); |
2509 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2514 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2515 | if ( syncManager->syncWithDesktop() ) { |
2516 | remote->removeSyncInfo( QString());//remove all info | ||
2517 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | ||
2518 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | ||
2519 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | ||
2520 | } else { | ||
2521 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | ||
2522 | } | ||
2523 | } | ||
2524 | QDateTime modifiedCalendar = mLastAddressbookSync; | ||
2511 | addresseeLSync = getLastSyncAddressee(); | 2525 | addresseeLSync = getLastSyncAddressee(); |
2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2526 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2527 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2514 | if ( !addresseeR.isEmpty() ) { | 2528 | if ( !addresseeR.isEmpty() ) { |
2515 | addresseeRSync = addresseeR; | 2529 | addresseeRSync = addresseeR; |
2516 | remote->removeAddressee(addresseeR ); | 2530 | remote->removeAddressee(addresseeR ); |
2517 | 2531 | ||
2518 | } else { | 2532 | } else { |
2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2520 | addresseeRSync = addresseeLSync ; | 2534 | addresseeRSync = addresseeLSync ; |
2521 | } else { | 2535 | } else { |
2522 | qDebug("FULLDATE 1"); | 2536 | qDebug("FULLDATE 1"); |
2523 | fullDateRange = true; | 2537 | fullDateRange = true; |
2524 | Addressee newAdd; | 2538 | Addressee newAdd; |
2525 | addresseeRSync = newAdd; | 2539 | addresseeRSync = newAdd; |
2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2540 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2541 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2528 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2542 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2543 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2530 | } | 2544 | } |
2531 | } | 2545 | } |
2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2546 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2533 | qDebug("FULLDATE 2"); | 2547 | qDebug("FULLDATE 2"); |
2534 | fullDateRange = true; | 2548 | fullDateRange = true; |
2535 | } | 2549 | } |
2536 | if ( ! fullDateRange ) { | 2550 | if ( ! fullDateRange ) { |
2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2551 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2538 | 2552 | ||
2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2553 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2554 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2541 | fullDateRange = true; | 2555 | fullDateRange = true; |
2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2556 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2543 | } | 2557 | } |
2544 | } | 2558 | } |
2545 | // fullDateRange = true; // debug only! | 2559 | // fullDateRange = true; // debug only! |
2546 | if ( fullDateRange ) | 2560 | if ( fullDateRange ) |
2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2561 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2548 | else | 2562 | else |
2549 | mLastAddressbookSync = addresseeLSync.revision(); | 2563 | mLastAddressbookSync = addresseeLSync.revision(); |
2550 | // for resyncing if own file has changed | 2564 | // for resyncing if own file has changed |
2551 | // PENDING fixme later when implemented | 2565 | // PENDING fixme later when implemented |
2552 | #if 0 | 2566 | #if 0 |
2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2567 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2554 | mLastAddressbookSync = loadedFileVersion; | 2568 | mLastAddressbookSync = loadedFileVersion; |
2555 | qDebug("setting mLastAddressbookSync "); | 2569 | qDebug("setting mLastAddressbookSync "); |
2556 | } | 2570 | } |
2557 | #endif | 2571 | #endif |
2558 | 2572 | ||
@@ -2560,96 +2574,98 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2574 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2561 | QStringList er = remote->uidList(); | 2575 | QStringList er = remote->uidList(); |
2562 | Addressee inR ;//= er.first(); | 2576 | Addressee inR ;//= er.first(); |
2563 | Addressee inL; | 2577 | Addressee inL; |
2564 | 2578 | ||
2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2579 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2566 | 2580 | ||
2567 | int modulo = (er.count()/10)+1; | 2581 | int modulo = (er.count()/10)+1; |
2568 | int incCounter = 0; | 2582 | int incCounter = 0; |
2569 | while ( incCounter < er.count()) { | 2583 | while ( incCounter < er.count()) { |
2570 | if (syncManager->isProgressBarCanceled()) | 2584 | if (syncManager->isProgressBarCanceled()) |
2571 | return false; | 2585 | return false; |
2572 | if ( incCounter % modulo == 0 ) | 2586 | if ( incCounter % modulo == 0 ) |
2573 | syncManager->showProgressBar(incCounter); | 2587 | syncManager->showProgressBar(incCounter); |
2574 | 2588 | ||
2575 | uid = er[ incCounter ]; | 2589 | uid = er[ incCounter ]; |
2576 | bool skipIncidence = false; | 2590 | bool skipIncidence = false; |
2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2591 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2578 | skipIncidence = true; | 2592 | skipIncidence = true; |
2579 | QString idS,OidS; | 2593 | QString idS,OidS; |
2580 | qApp->processEvents(); | 2594 | qApp->processEvents(); |
2581 | if ( !skipIncidence ) { | 2595 | if ( !skipIncidence ) { |
2582 | inL = local->findByUid( uid ); | 2596 | inL = local->findByUid( uid ); |
2583 | inR = remote->findByUid( uid ); | 2597 | inR = remote->findByUid( uid ); |
2584 | //inL.setResource( 0 ); | 2598 | //inL.setResource( 0 ); |
2585 | //inR.setResource( 0 ); | 2599 | //inR.setResource( 0 ); |
2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2600 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2601 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2602 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2603 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2590 | if ( take == 3 ) | 2604 | if ( take == 3 ) |
2591 | return false; | 2605 | return false; |
2592 | if ( take == 1 ) {// take local | 2606 | if ( take == 1 ) {// take local |
2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2607 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2608 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2609 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2596 | local->insertAddressee( inL, false ); | 2610 | local->insertAddressee( inL, false ); |
2597 | idS = inR.externalUID(); | 2611 | idS = inR.externalUID(); |
2598 | OidS = inR.originalExternalUID(); | 2612 | OidS = inR.originalExternalUID(); |
2599 | } | 2613 | } |
2600 | else | 2614 | else |
2601 | idS = inR.IDStr(); | 2615 | idS = inR.IDStr(); |
2602 | remote->removeAddressee( inR ); | 2616 | remote->removeAddressee( inR ); |
2603 | inR = inL; | 2617 | inR = inL; |
2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2618 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2606 | inR.setOriginalExternalUID( OidS ); | 2620 | inR.setOriginalExternalUID( OidS ); |
2607 | inR.setExternalUID( idS ); | 2621 | inR.setExternalUID( idS ); |
2622 | if ( syncManager->syncWithDesktop() ) | ||
2623 | inR.setIDStr( "changed" ); | ||
2608 | } else { | 2624 | } else { |
2609 | inR.setIDStr( idS ); | 2625 | inR.setIDStr( idS ); |
2610 | } | 2626 | } |
2611 | inR.setResource( 0 ); | 2627 | inR.setResource( 0 ); |
2612 | remote->insertAddressee( inR , false); | 2628 | remote->insertAddressee( inR , false); |
2613 | ++changedRemote; | 2629 | ++changedRemote; |
2614 | } else { // take == 2 take remote | 2630 | } else { // take == 2 take remote |
2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2631 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2616 | if ( inR.revision().date().year() < 2004 ) | 2632 | if ( inR.revision().date().year() < 2004 ) |
2617 | inR.setRevision( modifiedCalendar ); | 2633 | inR.setRevision( modifiedCalendar ); |
2618 | } | 2634 | } |
2619 | idS = inL.IDStr(); | 2635 | idS = inL.IDStr(); |
2620 | local->removeAddressee( inL ); | 2636 | local->removeAddressee( inL ); |
2621 | inL = inR; | 2637 | inL = inR; |
2622 | inL.setIDStr( idS ); | 2638 | inL.setIDStr( idS ); |
2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2640 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2641 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2626 | } | 2642 | } |
2627 | inL.setResource( 0 ); | 2643 | inL.setResource( 0 ); |
2628 | local->insertAddressee( inL , false ); | 2644 | local->insertAddressee( inL , false ); |
2629 | ++changedLocal; | 2645 | ++changedLocal; |
2630 | } | 2646 | } |
2631 | } | 2647 | } |
2632 | } | 2648 | } |
2633 | } else { // no conflict | 2649 | } else { // no conflict |
2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2635 | QString des = addresseeLSync.note(); | 2651 | QString des = addresseeLSync.note(); |
2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2652 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2653 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2638 | remote->insertAddressee( inR, false ); | 2654 | remote->insertAddressee( inR, false ); |
2639 | ++deletedAddresseeR; | 2655 | ++deletedAddresseeR; |
2640 | } else { | 2656 | } else { |
2641 | inR.setRevision( modifiedCalendar ); | 2657 | inR.setRevision( modifiedCalendar ); |
2642 | remote->insertAddressee( inR, false ); | 2658 | remote->insertAddressee( inR, false ); |
2643 | inL = inR; | 2659 | inL = inR; |
2644 | inL.setResource( 0 ); | 2660 | inL.setResource( 0 ); |
2645 | local->insertAddressee( inL , false); | 2661 | local->insertAddressee( inL , false); |
2646 | ++addedAddressee; | 2662 | ++addedAddressee; |
2647 | } | 2663 | } |
2648 | } else { | 2664 | } else { |
2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2665 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2650 | inR.setRevision( modifiedCalendar ); | 2666 | inR.setRevision( modifiedCalendar ); |
2651 | remote->insertAddressee( inR, false ); | 2667 | remote->insertAddressee( inR, false ); |
2652 | inR.setResource( 0 ); | 2668 | inR.setResource( 0 ); |
2653 | local->insertAddressee( inR, false ); | 2669 | local->insertAddressee( inR, false ); |
2654 | ++addedAddressee; | 2670 | ++addedAddressee; |
2655 | } else { | 2671 | } else { |
@@ -2852,65 +2868,68 @@ void KABCore::message( QString m ) | |||
2852 | topLevelWidget()->setCaption( m ); | 2868 | topLevelWidget()->setCaption( m ); |
2853 | mMessageTimer->start( 15000, true ); | 2869 | mMessageTimer->start( 15000, true ); |
2854 | } | 2870 | } |
2855 | bool KABCore::syncPhone() | 2871 | bool KABCore::syncPhone() |
2856 | { | 2872 | { |
2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2873 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2858 | QString fileName = getPhoneFile(); | 2874 | QString fileName = getPhoneFile(); |
2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2875 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2860 | message(i18n("Phone access failed!")); | 2876 | message(i18n("Phone access failed!")); |
2861 | return false; | 2877 | return false; |
2862 | } | 2878 | } |
2863 | AddressBook abLocal( fileName,"syncContact"); | 2879 | AddressBook abLocal( fileName,"syncContact"); |
2864 | bool syncOK = false; | 2880 | bool syncOK = false; |
2865 | { | 2881 | { |
2866 | abLocal.importFromFile( fileName ); | 2882 | abLocal.importFromFile( fileName ); |
2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2883 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2884 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2885 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2872 | if ( syncOK ) { | 2888 | if ( syncOK ) { |
2873 | if ( syncManager->mWriteBackFile ) { | 2889 | if ( syncManager->mWriteBackFile ) { |
2874 | abLocal.removeSyncAddressees( true ); | 2890 | abLocal.removeSyncAddressees( true ); |
2875 | abLocal.saveABphone( fileName ); | 2891 | abLocal.saveABphone( fileName ); |
2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2892 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2893 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2894 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2879 | } | 2895 | } |
2880 | } | 2896 | } |
2881 | setModified(); | 2897 | setModified(); |
2882 | } | 2898 | } |
2883 | if ( syncOK ) | 2899 | if ( syncOK ) |
2884 | mViewManager->refreshView(); | 2900 | mViewManager->refreshView(); |
2885 | return syncOK; | 2901 | return syncOK; |
2886 | } | 2902 | } |
2887 | void KABCore::getFile( bool success ) | 2903 | void KABCore::getFile( bool success ) |
2888 | { | 2904 | { |
2889 | if ( ! success ) { | 2905 | if ( ! success ) { |
2890 | message( i18n("Error receiving file. Nothing changed!") ); | 2906 | message( i18n("Error receiving file. Nothing changed!") ); |
2891 | return; | 2907 | return; |
2892 | } | 2908 | } |
2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2909 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2894 | if ( count ) | 2910 | if ( count ) |
2895 | setModified( true ); | 2911 | setModified( true ); |
2896 | message( i18n("Pi-Sync successful!") ); | 2912 | message( i18n("Pi-Sync successful!") ); |
2897 | mViewManager->refreshView(); | 2913 | mViewManager->refreshView(); |
2898 | } | 2914 | } |
2899 | void KABCore::syncFileRequest() | 2915 | void KABCore::syncFileRequest() |
2900 | { | 2916 | { |
2917 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | ||
2918 | syncManager->slotSyncMenu( 999 ); | ||
2919 | } | ||
2901 | mAddressBook->export2File( sentSyncFile() ); | 2920 | mAddressBook->export2File( sentSyncFile() ); |
2902 | } | 2921 | } |
2903 | QString KABCore::sentSyncFile() | 2922 | QString KABCore::sentSyncFile() |
2904 | { | 2923 | { |
2905 | #ifdef DESKTOP_VERSION | 2924 | #ifdef DESKTOP_VERSION |
2906 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2925 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2907 | #else | 2926 | #else |
2908 | return QString( "/tmp/copysyncab.vcf" ); | 2927 | return QString( "/tmp/copysyncab.vcf" ); |
2909 | #endif | 2928 | #endif |
2910 | } | 2929 | } |
2911 | 2930 | ||
2912 | void KABCore::setCaptionBack() | 2931 | void KABCore::setCaptionBack() |
2913 | { | 2932 | { |
2914 | mMessageTimer->stop(); | 2933 | mMessageTimer->stop(); |
2915 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2934 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2916 | } | 2935 | } |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index f4fb08b..81e0d99 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -255,96 +255,101 @@ void ViewManager::setActiveView( const QString &name ) | |||
255 | // If we found or created the view, raise it and refresh it | 255 | // If we found or created the view, raise it and refresh it |
256 | if ( view ) { | 256 | if ( view ) { |
257 | mActiveView = view; | 257 | mActiveView = view; |
258 | mViewWidgetStack->raiseWidget( view ); | 258 | mViewWidgetStack->raiseWidget( view ); |
259 | // Set the proper filter in the view. By setting the combo | 259 | // Set the proper filter in the view. By setting the combo |
260 | // box, the activated slot will be called, which will push | 260 | // box, the activated slot will be called, which will push |
261 | // the filter to the view and refresh it. | 261 | // the filter to the view and refresh it. |
262 | 262 | ||
263 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 263 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
264 | 264 | ||
265 | mActionSelectFilter->setCurrentItem( 0 ); | 265 | mActionSelectFilter->setCurrentItem( 0 ); |
266 | setActiveFilter( 0 ); | 266 | setActiveFilter( 0 ); |
267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
268 | setActiveFilter( mActionSelectFilter->currentItem() ); | 268 | setActiveFilter( mActionSelectFilter->currentItem() ); |
269 | } else { | 269 | } else { |
270 | uint pos = filterPosition( view->defaultFilterName() ); | 270 | uint pos = filterPosition( view->defaultFilterName() ); |
271 | mActionSelectFilter->setCurrentItem( pos ); | 271 | mActionSelectFilter->setCurrentItem( pos ); |
272 | setActiveFilter( pos ); | 272 | setActiveFilter( pos ); |
273 | } | 273 | } |
274 | //US qDebug("ViewManager::setActiveView 6" ); | 274 | //US qDebug("ViewManager::setActiveView 6" ); |
275 | 275 | ||
276 | // Update the inc search widget to show the fields in the new active | 276 | // Update the inc search widget to show the fields in the new active |
277 | // view. | 277 | // view. |
278 | mCore->setSearchFields( mActiveView->fields() ); | 278 | mCore->setSearchFields( mActiveView->fields() ); |
279 | 279 | ||
280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
281 | //US mActiveView->refresh(); | 281 | //US mActiveView->refresh(); |
282 | 282 | ||
283 | } | 283 | } |
284 | else | 284 | else |
285 | { | 285 | { |
286 | qDebug("ViewManager::setActiveView: unable to find view" ); | 286 | qDebug("ViewManager::setActiveView: unable to find view" ); |
287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 291 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
292 | void ViewManager::refreshView() | 292 | void ViewManager::refreshView() |
293 | { | 293 | { |
294 | refreshView( QString::null ); | 294 | refreshView( QString::null ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void ViewManager::refreshView( const QString &uid ) | 297 | void ViewManager::refreshView( const QString &uid ) |
298 | { | 298 | { |
299 | if ( mActiveView ) | 299 | if ( mActiveView ) |
300 | mActiveView->refresh( uid ); | 300 | mActiveView->refresh( uid ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ViewManager::setFocusAV() | ||
304 | { | ||
305 | if ( mActiveView ) | ||
306 | mActiveView->setFocus(); | ||
307 | } | ||
303 | void ViewManager::editView() | 308 | void ViewManager::editView() |
304 | { | 309 | { |
305 | if ( !mActiveView ) | 310 | if ( !mActiveView ) |
306 | return; | 311 | return; |
307 | 312 | ||
308 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 313 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
309 | ViewConfigureWidget *wdg = 0; | 314 | ViewConfigureWidget *wdg = 0; |
310 | ViewConfigureDialog* dlg = 0; | 315 | ViewConfigureDialog* dlg = 0; |
311 | if ( factory ) { | 316 | if ( factory ) { |
312 | // Save the filters so the dialog has the latest set | 317 | // Save the filters so the dialog has the latest set |
313 | Filter::save( mCore->config(), "Filter", mFilterList ); | 318 | Filter::save( mCore->config(), "Filter", mFilterList ); |
314 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 319 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
315 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 320 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
316 | } else { | 321 | } else { |
317 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 322 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
318 | return; | 323 | return; |
319 | } | 324 | } |
320 | if ( wdg ) { | 325 | if ( wdg ) { |
321 | dlg->setWidget( wdg ); | 326 | dlg->setWidget( wdg ); |
322 | 327 | ||
323 | #ifndef DESKTOP_VERSION | 328 | #ifndef DESKTOP_VERSION |
324 | //dlg.setMaximumSize( 640, 480 ); | 329 | //dlg.setMaximumSize( 640, 480 ); |
325 | //dlg->setGeometry( 40,40, 400, 300); | 330 | //dlg->setGeometry( 40,40, 400, 300); |
326 | dlg->showMaximized(); | 331 | dlg->showMaximized(); |
327 | #endif | 332 | #endif |
328 | 333 | ||
329 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 334 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
330 | 335 | ||
331 | dlg->restoreSettings( mCore->config() ); | 336 | dlg->restoreSettings( mCore->config() ); |
332 | 337 | ||
333 | if ( dlg->exec() ) { | 338 | if ( dlg->exec() ) { |
334 | dlg->saveSettings( mCore->config() ); | 339 | dlg->saveSettings( mCore->config() ); |
335 | mActiveView->readConfig( mCore->config() ); | 340 | mActiveView->readConfig( mCore->config() ); |
336 | 341 | ||
337 | // Set the proper filter in the view. By setting the combo | 342 | // Set the proper filter in the view. By setting the combo |
338 | // box, the activated slot will be called, which will push | 343 | // box, the activated slot will be called, which will push |
339 | // the filter to the view and refresh it. | 344 | // the filter to the view and refresh it. |
340 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 345 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
341 | mActionSelectFilter->setCurrentItem( 0 ); | 346 | mActionSelectFilter->setCurrentItem( 0 ); |
342 | setActiveFilter( 0 ); | 347 | setActiveFilter( 0 ); |
343 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 348 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
344 | setActiveFilter( mActionSelectFilter->currentItem() ); | 349 | setActiveFilter( mActionSelectFilter->currentItem() ); |
345 | } else { | 350 | } else { |
346 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 351 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
347 | mActionSelectFilter->setCurrentItem( pos ); | 352 | mActionSelectFilter->setCurrentItem( pos ); |
348 | setActiveFilter( pos ); | 353 | setActiveFilter( pos ); |
349 | } | 354 | } |
350 | mCore->setSearchFields( mActiveView->fields() ); | 355 | mCore->setSearchFields( mActiveView->fields() ); |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 585f4e9..a03a83f 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -19,96 +19,97 @@ | |||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | 31 | ||
32 | class KAction; | 32 | class KAction; |
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace KABC { class AddressBook; } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | The view manager manages the views and everything related to them. The | 42 | The view manager manages the views and everything related to them. The |
43 | manager will load the views at startup and display a view when told to | 43 | manager will load the views at startup and display a view when told to |
44 | make one active. | 44 | make one active. |
45 | 45 | ||
46 | The view manager will also create and manage all dialogs directly related to | 46 | The view manager will also create and manage all dialogs directly related to |
47 | views (ie: AddView, ConfigureView, DeleteView, etc). | 47 | views (ie: AddView, ConfigureView, DeleteView, etc). |
48 | */ | 48 | */ |
49 | class ViewManager : public QWidget | 49 | class ViewManager : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
54 | ~ViewManager(); | 54 | ~ViewManager(); |
55 | 55 | ||
56 | void restoreSettings(); | 56 | void restoreSettings(); |
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | void doSearch( const QString& s ,KABC::Field *field ); | 58 | void doSearch( const QString& s ,KABC::Field *field ); |
59 | 59 | ||
60 | void unloadViews(); | 60 | void unloadViews(); |
61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
62 | 62 | ||
63 | QStringList selectedUids() const; | 63 | QStringList selectedUids() const; |
64 | QStringList selectedEmails() const; | 64 | QStringList selectedEmails() const; |
65 | KABC::Addressee::List selectedAddressees() const; | 65 | KABC::Addressee::List selectedAddressees() const; |
66 | void setListSelected(QStringList); | 66 | void setListSelected(QStringList); |
67 | void setFocusAV(); | ||
67 | 68 | ||
68 | public slots: | 69 | public slots: |
69 | void scrollUP(); | 70 | void scrollUP(); |
70 | void scrollDOWN(); | 71 | void scrollDOWN(); |
71 | 72 | ||
72 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 73 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
73 | void setSelected( const QString &uid, bool); | 74 | void setSelected( const QString &uid, bool); |
74 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 75 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
75 | void setSelected(); | 76 | void setSelected(); |
76 | 77 | ||
77 | 78 | ||
78 | 79 | ||
79 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 80 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
80 | void refreshView(); | 81 | void refreshView(); |
81 | void refreshView( const QString &uid); | 82 | void refreshView( const QString &uid); |
82 | 83 | ||
83 | void editView(); | 84 | void editView(); |
84 | void deleteView(); | 85 | void deleteView(); |
85 | void addView(); | 86 | void addView(); |
86 | 87 | ||
87 | protected slots: | 88 | protected slots: |
88 | /** | 89 | /** |
89 | Called whenever the user drops something in the active view. | 90 | Called whenever the user drops something in the active view. |
90 | This method will try to decode what was dropped, and if it was | 91 | This method will try to decode what was dropped, and if it was |
91 | a valid addressee, add it to the addressbook. | 92 | a valid addressee, add it to the addressbook. |
92 | */ | 93 | */ |
93 | void dropped( QDropEvent* ); | 94 | void dropped( QDropEvent* ); |
94 | 95 | ||
95 | /** | 96 | /** |
96 | Called whenever the user attempts to start a drag in the view. | 97 | Called whenever the user attempts to start a drag in the view. |
97 | This method will convert all the selected addressees into text (vcard) | 98 | This method will convert all the selected addressees into text (vcard) |
98 | and create a drag object. | 99 | and create a drag object. |
99 | */ | 100 | */ |
100 | void startDrag(); | 101 | void startDrag(); |
101 | 102 | ||
102 | signals: | 103 | signals: |
103 | /** | 104 | /** |
104 | Emitted whenever the user selects an entry in the view. | 105 | Emitted whenever the user selects an entry in the view. |
105 | */ | 106 | */ |
106 | void selected( const QString &uid ); | 107 | void selected( const QString &uid ); |
107 | void deleteRequest( ); | 108 | void deleteRequest( ); |
108 | 109 | ||
109 | /** | 110 | /** |
110 | Emitted whenever the user activates an entry in the view. | 111 | Emitted whenever the user activates an entry in the view. |
111 | */ | 112 | */ |
112 | void executed( const QString &uid ); | 113 | void executed( const QString &uid ); |
113 | 114 | ||
114 | /** | 115 | /** |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 326db88..6e61351 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -882,205 +882,205 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t | |||
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncKDE ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync;; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncKDE ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncKDE ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else { | 1033 | } else { |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncKDE ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict | 1049 | } else { // no conflict |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | local->addIncidence( inL ); | 1063 | local->addIncidence( inL ); |
1064 | ++addedEvent; | 1064 | ++addedEvent; |
1065 | } | 1065 | } |
1066 | } else { | 1066 | } else { |
1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1068 | inR->setLastModified( modifiedCalendar ); | 1068 | inR->setLastModified( modifiedCalendar ); |
1069 | inL = inR->clone(); | 1069 | inL = inR->clone(); |
1070 | inL->setIDStr( ":" ); | 1070 | inL->setIDStr( ":" ); |
1071 | local->addIncidence( inL ); | 1071 | local->addIncidence( inL ); |
1072 | ++addedEvent; | 1072 | ++addedEvent; |
1073 | } else { | 1073 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1074 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1075 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1076 | ++deletedEventR; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | inR = er.next(); | 1081 | inR = er.next(); |
1082 | } | 1082 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1083 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1084 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1085 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1086 | bar.setCaption (i18n("Add / remove events") ); |
@@ -1138,97 +1138,97 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1138 | } | 1138 | } |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | inL = el.next(); | 1142 | inL = el.next(); |
1143 | } | 1143 | } |
1144 | int delFut = 0; | 1144 | int delFut = 0; |
1145 | int remRem = 0; | 1145 | int remRem = 0; |
1146 | if ( mSyncManager->mWriteBackInFuture ) { | 1146 | if ( mSyncManager->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1147 | er = remote->rawIncidences(); |
1148 | remRem = er.count(); | 1148 | remRem = er.count(); |
1149 | inR = er.first(); | 1149 | inR = er.first(); |
1150 | QDateTime dt; | 1150 | QDateTime dt; |
1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1153 | while ( inR ) { | 1153 | while ( inR ) { |
1154 | if ( inR->type() == "Todo" ) { | 1154 | if ( inR->type() == "Todo" ) { |
1155 | Todo * t = (Todo*)inR; | 1155 | Todo * t = (Todo*)inR; |
1156 | if ( t->hasDueDate() ) | 1156 | if ( t->hasDueDate() ) |
1157 | dt = t->dtDue(); | 1157 | dt = t->dtDue(); |
1158 | else | 1158 | else |
1159 | dt = cur.addSecs( 62 ); | 1159 | dt = cur.addSecs( 62 ); |
1160 | } | 1160 | } |
1161 | else if (inR->type() == "Event" ) { | 1161 | else if (inR->type() == "Event" ) { |
1162 | bool ok; | 1162 | bool ok; |
1163 | dt = inR->getNextOccurence( cur, &ok ); | 1163 | dt = inR->getNextOccurence( cur, &ok ); |
1164 | if ( !ok ) | 1164 | if ( !ok ) |
1165 | dt = cur.addSecs( -62 ); | 1165 | dt = cur.addSecs( -62 ); |
1166 | } | 1166 | } |
1167 | else | 1167 | else |
1168 | dt = inR->dtStart(); | 1168 | dt = inR->dtStart(); |
1169 | if ( dt < cur || dt > end ) { | 1169 | if ( dt < cur || dt > end ) { |
1170 | remote->deleteIncidence( inR ); | 1170 | remote->deleteIncidence( inR ); |
1171 | ++delFut; | 1171 | ++delFut; |
1172 | } | 1172 | } |
1173 | inR = er.next(); | 1173 | inR = er.next(); |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | bar.hide(); | 1176 | bar.hide(); |
1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1178 | eventLSync->setReadOnly( false ); | 1178 | eventLSync->setReadOnly( false ); |
1179 | eventLSync->setDtStart( mLastCalendarSync ); | 1179 | eventLSync->setDtStart( mLastCalendarSync ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1180 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1185 | eventLSync->setReadOnly( true ); | 1185 | eventLSync->setReadOnly( true ); |
1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1187 | remote->addEvent( eventRSync ); | 1187 | remote->addEvent( eventRSync ); |
1188 | else | 1188 | else |
1189 | delete eventRSync; | 1189 | delete eventRSync; |
1190 | QString mes; | 1190 | QString mes; |
1191 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1191 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1192 | QString delmess; | 1192 | QString delmess; |
1193 | if ( delFut ) { | 1193 | if ( delFut ) { |
1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1195 | mes += delmess; | 1195 | mes += delmess; |
1196 | } | 1196 | } |
1197 | if ( mSyncManager->mShowSyncSummary ) { | 1197 | if ( mSyncManager->mShowSyncSummary ) { |
1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1199 | } | 1199 | } |
1200 | qDebug( mes ); | 1200 | qDebug( mes ); |
1201 | mCalendar->checkAlarmForIncidence( 0, true ); | 1201 | mCalendar->checkAlarmForIncidence( 0, true ); |
1202 | return syncOK; | 1202 | return syncOK; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | void CalendarView::setSyncDevice( QString s ) | 1205 | void CalendarView::setSyncDevice( QString s ) |
1206 | { | 1206 | { |
1207 | mCurrentSyncDevice= s; | 1207 | mCurrentSyncDevice= s; |
1208 | } | 1208 | } |
1209 | void CalendarView::setSyncName( QString s ) | 1209 | void CalendarView::setSyncName( QString s ) |
1210 | { | 1210 | { |
1211 | mCurrentSyncName= s; | 1211 | mCurrentSyncName= s; |
1212 | } | 1212 | } |
1213 | bool CalendarView::syncCalendar(QString filename, int mode) | 1213 | bool CalendarView::syncCalendar(QString filename, int mode) |
1214 | { | 1214 | { |
1215 | //qDebug("syncCalendar %s ", filename.latin1()); | 1215 | //qDebug("syncCalendar %s ", filename.latin1()); |
1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1217 | CalendarLocal* calendar = new CalendarLocal(); | 1217 | CalendarLocal* calendar = new CalendarLocal(); |
1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1219 | FileStorage* storage = new FileStorage( calendar ); | 1219 | FileStorage* storage = new FileStorage( calendar ); |
1220 | bool syncOK = false; | 1220 | bool syncOK = false; |
1221 | storage->setFileName( filename ); | 1221 | storage->setFileName( filename ); |
1222 | // qDebug("loading ... "); | 1222 | // qDebug("loading ... "); |
1223 | if ( storage->load() ) { | 1223 | if ( storage->load() ) { |
1224 | getEventViewerDialog()->setSyncMode( true ); | 1224 | getEventViewerDialog()->setSyncMode( true ); |
1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1226 | getEventViewerDialog()->setSyncMode( false ); | 1226 | getEventViewerDialog()->setSyncMode( false ); |
1227 | if ( syncOK ) { | 1227 | if ( syncOK ) { |
1228 | if ( mSyncManager->mWriteBackFile ) | 1228 | if ( mSyncManager->mWriteBackFile ) |
1229 | { | 1229 | { |
1230 | storage->setSaveFormat( new ICalFormat() ); | 1230 | storage->setSaveFormat( new ICalFormat() ); |
1231 | storage->save(); | 1231 | storage->save(); |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | setModified( true ); | 1234 | setModified( true ); |
@@ -3700,81 +3700,78 @@ void CalendarView::purgeCompleted() | |||
3700 | { | 3700 | { |
3701 | int result = KMessageBox::warningContinueCancel(this, | 3701 | int result = KMessageBox::warningContinueCancel(this, |
3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3703 | 3703 | ||
3704 | if (result == KMessageBox::Continue) { | 3704 | if (result == KMessageBox::Continue) { |
3705 | 3705 | ||
3706 | QPtrList<Todo> todoCal; | 3706 | QPtrList<Todo> todoCal; |
3707 | QPtrList<Todo> rootTodos; | 3707 | QPtrList<Todo> rootTodos; |
3708 | //QPtrList<Incidence> rel; | 3708 | //QPtrList<Incidence> rel; |
3709 | Todo *aTodo;//, *rTodo; | 3709 | Todo *aTodo;//, *rTodo; |
3710 | Incidence *rIncidence; | 3710 | Incidence *rIncidence; |
3711 | bool childDelete = false; | 3711 | bool childDelete = false; |
3712 | bool deletedOne = true; | 3712 | bool deletedOne = true; |
3713 | todoCal = calendar()->todos(); | 3713 | todoCal = calendar()->todos(); |
3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3715 | if ( !aTodo->relatedTo() ) | 3715 | if ( !aTodo->relatedTo() ) |
3716 | rootTodos.append( aTodo ); | 3716 | rootTodos.append( aTodo ); |
3717 | } | 3717 | } |
3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3719 | removeCompletedSubTodos( aTodo ); | 3719 | removeCompletedSubTodos( aTodo ); |
3720 | } | 3720 | } |
3721 | 3721 | ||
3722 | updateView(); | 3722 | updateView(); |
3723 | } | 3723 | } |
3724 | } | 3724 | } |
3725 | 3725 | ||
3726 | void CalendarView::slotCalendarChanged() | 3726 | void CalendarView::slotCalendarChanged() |
3727 | { | 3727 | { |
3728 | ; | 3728 | ; |
3729 | } | 3729 | } |
3730 | 3730 | ||
3731 | NavigatorBar *CalendarView::navigatorBar() | 3731 | NavigatorBar *CalendarView::navigatorBar() |
3732 | { | 3732 | { |
3733 | return mNavigatorBar; | 3733 | return mNavigatorBar; |
3734 | } | 3734 | } |
3735 | 3735 | ||
3736 | 3736 | ||
3737 | 3737 | ||
3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3739 | { | 3739 | { |
3740 | //qDebug(" alendarView::keyPressEvent "); | 3740 | //qDebug(" alendarView::keyPressEvent "); |
3741 | e->ignore(); | 3741 | e->ignore(); |
3742 | } | 3742 | } |
3743 | 3743 | ||
3744 | 3744 | ||
3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3746 | { | 3746 | { |
3747 | // mSyncManager = manager; | 3747 | // mSyncManager = manager; |
3748 | mSyncKDE = false; | ||
3749 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3748 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3750 | qDebug("SyncKDE request detected!"); | 3749 | qDebug("SyncKDE request detected!"); |
3751 | mSyncKDE = true; | ||
3752 | } | 3750 | } |
3753 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3754 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3755 | return syncCalendar( filename, mode ); | 3753 | return syncCalendar( filename, mode ); |
3756 | } | 3754 | } |
3757 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3755 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3758 | { | 3756 | { |
3759 | mSyncKDE = false; | ||
3760 | //mSyncManager = manager; | 3757 | //mSyncManager = manager; |
3761 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3758 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3762 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3759 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3763 | if ( resource == "sharp" ) | 3760 | if ( resource == "sharp" ) |
3764 | syncExternal( 0 ); | 3761 | syncExternal( 0 ); |
3765 | if ( resource == "phone" ) | 3762 | if ( resource == "phone" ) |
3766 | syncExternal( 1 ); | 3763 | syncExternal( 1 ); |
3767 | // pending setmodified | 3764 | // pending setmodified |
3768 | return true; | 3765 | return true; |
3769 | } | 3766 | } |
3770 | void CalendarView::setSyncManager(KSyncManager* manager) | 3767 | void CalendarView::setSyncManager(KSyncManager* manager) |
3771 | { | 3768 | { |
3772 | mSyncManager = manager; | 3769 | mSyncManager = manager; |
3773 | } | 3770 | } |
3774 | 3771 | ||
3775 | void CalendarView::removeSyncInfo( QString syncProfile) | 3772 | void CalendarView::removeSyncInfo( QString syncProfile) |
3776 | { | 3773 | { |
3777 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3774 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3778 | mCalendar->removeSyncInfo( syncProfile ); | 3775 | mCalendar->removeSyncInfo( syncProfile ); |
3779 | 3776 | ||
3780 | } | 3777 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index acc20d6..437a51c 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -444,97 +444,96 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
444 | void beamIncidence(Incidence *) ; | 444 | void beamIncidence(Incidence *) ; |
445 | void beamCalendar() ; | 445 | void beamCalendar() ; |
446 | void beamFilteredCalendar() ; | 446 | void beamFilteredCalendar() ; |
447 | void beamIncidenceList(QPtrList<Incidence>) ; | 447 | void beamIncidenceList(QPtrList<Incidence>) ; |
448 | void manageCategories(); | 448 | void manageCategories(); |
449 | int addCategories(); | 449 | int addCategories(); |
450 | void removeCategories(); | 450 | void removeCategories(); |
451 | void setSyncDevice( QString ); | 451 | void setSyncDevice( QString ); |
452 | void setSyncName( QString ); | 452 | void setSyncName( QString ); |
453 | protected slots: | 453 | protected slots: |
454 | void timerAlarm(); | 454 | void timerAlarm(); |
455 | void suspendAlarm(); | 455 | void suspendAlarm(); |
456 | void beamDone( Ir *ir ); | 456 | void beamDone( Ir *ir ); |
457 | /** Select a view or adapt the current view to display the specified dates. */ | 457 | /** Select a view or adapt the current view to display the specified dates. */ |
458 | void showDates( const KCal::DateList & ); | 458 | void showDates( const KCal::DateList & ); |
459 | void selectWeekNum ( int ); | 459 | void selectWeekNum ( int ); |
460 | 460 | ||
461 | public: | 461 | public: |
462 | // show a standard warning | 462 | // show a standard warning |
463 | // returns KMsgBox::yesNoCancel() | 463 | // returns KMsgBox::yesNoCancel() |
464 | int msgCalModified(); | 464 | int msgCalModified(); |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | 466 | ||
467 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 467 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
468 | virtual void removeSyncInfo( QString syncProfile); | 468 | virtual void removeSyncInfo( QString syncProfile); |
469 | void setSyncManager(KSyncManager* manager); | 469 | void setSyncManager(KSyncManager* manager); |
470 | void setLoadedFileVersion(QDateTime); | 470 | void setLoadedFileVersion(QDateTime); |
471 | bool checkFileVersion(QString fn); | 471 | bool checkFileVersion(QString fn); |
472 | bool checkFileChanged(QString fn); | 472 | bool checkFileChanged(QString fn); |
473 | Event* getLastSyncEvent(); | 473 | Event* getLastSyncEvent(); |
474 | /** Adapt navigation units correpsonding to step size of navigation of the | 474 | /** Adapt navigation units correpsonding to step size of navigation of the |
475 | * current view. | 475 | * current view. |
476 | */ | 476 | */ |
477 | void adaptNavigationUnits(); | 477 | void adaptNavigationUnits(); |
478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
480 | //Attendee* getYourAttendee(Event *event); | 480 | //Attendee* getYourAttendee(Event *event); |
481 | protected: | 481 | protected: |
482 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 482 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
483 | 483 | ||
484 | // returns KMsgBox::OKCandel() | 484 | // returns KMsgBox::OKCandel() |
485 | int msgItemDelete(); | 485 | int msgItemDelete(); |
486 | void showEventEditor(); | 486 | void showEventEditor(); |
487 | void showTodoEditor(); | 487 | void showTodoEditor(); |
488 | void writeLocale(); | 488 | void writeLocale(); |
489 | Todo *selectedTodo(); | 489 | Todo *selectedTodo(); |
490 | 490 | ||
491 | private: | 491 | private: |
492 | bool mSyncKDE; | ||
493 | KSyncManager* mSyncManager; | 492 | KSyncManager* mSyncManager; |
494 | AlarmDialog * mAlarmDialog; | 493 | AlarmDialog * mAlarmDialog; |
495 | QString mAlarmNotification; | 494 | QString mAlarmNotification; |
496 | QString mSuspendAlarmNotification; | 495 | QString mSuspendAlarmNotification; |
497 | QTimer* mSuspendTimer; | 496 | QTimer* mSuspendTimer; |
498 | QTimer* mAlarmTimer; | 497 | QTimer* mAlarmTimer; |
499 | QTimer* mRecheckAlarmTimer; | 498 | QTimer* mRecheckAlarmTimer; |
500 | void computeAlarm( QString ); | 499 | void computeAlarm( QString ); |
501 | void startAlarm( QString, QString ); | 500 | void startAlarm( QString, QString ); |
502 | void setSyncEventsReadOnly(); | 501 | void setSyncEventsReadOnly(); |
503 | 502 | ||
504 | QDateTime loadedFileVersion; | 503 | QDateTime loadedFileVersion; |
505 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 504 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
506 | void checkExternalId( Incidence * inc ); | 505 | void checkExternalId( Incidence * inc ); |
507 | int mGlobalSyncMode; | 506 | int mGlobalSyncMode; |
508 | QString mCurrentSyncDevice; | 507 | QString mCurrentSyncDevice; |
509 | QString mCurrentSyncName; | 508 | QString mCurrentSyncName; |
510 | KOBeamPrefs* beamDialog; | 509 | KOBeamPrefs* beamDialog; |
511 | void init(); | 510 | void init(); |
512 | int mDatePickerMode; | 511 | int mDatePickerMode; |
513 | bool mFlagEditDescription; | 512 | bool mFlagEditDescription; |
514 | QDateTime mLastCalendarSync; | 513 | QDateTime mLastCalendarSync; |
515 | void createPrinter(); | 514 | void createPrinter(); |
516 | 515 | ||
517 | void calendarModified( bool, Calendar * ); | 516 | void calendarModified( bool, Calendar * ); |
518 | 517 | ||
519 | CalPrinter *mCalPrinter; | 518 | CalPrinter *mCalPrinter; |
520 | 519 | ||
521 | QSplitter *mPanner; | 520 | QSplitter *mPanner; |
522 | QSplitter *mLeftSplitter; | 521 | QSplitter *mLeftSplitter; |
523 | QWidget *mLeftFrame; | 522 | QWidget *mLeftFrame; |
524 | QWidgetStack *mRightFrame; | 523 | QWidgetStack *mRightFrame; |
525 | 524 | ||
526 | KDatePicker* mDatePicker; | 525 | KDatePicker* mDatePicker; |
527 | QVBox* mDateFrame; | 526 | QVBox* mDateFrame; |
528 | NavigatorBar *mNavigatorBar; | 527 | NavigatorBar *mNavigatorBar; |
529 | 528 | ||
530 | KDateNavigator *mDateNavigator; // widget showing small month view. | 529 | KDateNavigator *mDateNavigator; // widget showing small month view. |
531 | 530 | ||
532 | KOFilterView *mFilterView; | 531 | KOFilterView *mFilterView; |
533 | 532 | ||
534 | ResourceView *mResourceView; | 533 | ResourceView *mResourceView; |
535 | 534 | ||
536 | // calendar object for this viewing instance | 535 | // calendar object for this viewing instance |
537 | Calendar *mCalendar; | 536 | Calendar *mCalendar; |
538 | 537 | ||
539 | CalendarResourceManager *mResourceManager; | 538 | CalendarResourceManager *mResourceManager; |
540 | 539 | ||
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e09050e..17e6c75 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -142,160 +142,162 @@ void KSyncManager::fillSyncMenu() | |||
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | ||
190 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
191 | 192 | ||
192 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
193 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
194 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
195 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
196 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
197 | //confSync(); | 198 | //confSync(); |
198 | 199 | ||
199 | return; | 200 | return; |
200 | } | 201 | } |
201 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
202 | multiSync( true ); | 203 | multiSync( true ); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
206 | enableQuick(); | 207 | enableQuick(); |
207 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
208 | return; | 209 | return; |
209 | } | 210 | } |
210 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
211 | delete mServerSocket; | 212 | delete mServerSocket; |
212 | mServerSocket = 0; | 213 | mServerSocket = 0; |
213 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | 217 | ||
217 | if (blockSave()) | 218 | if (blockSave()) |
218 | return; | 219 | return; |
219 | 220 | ||
220 | setBlockSave(true); | 221 | setBlockSave(true); |
221 | bool silent = false; | 222 | bool silent = false; |
222 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
223 | //special mode for silent syncing | 224 | //special mode for silent syncing |
224 | action = 1000; | 225 | action = 1000; |
225 | silent = true; | 226 | silent = true; |
226 | } | 227 | } |
227 | 228 | ||
228 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
229 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
230 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
231 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
232 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
233 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
234 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
235 | if (silent) { | 236 | if (silent) { |
236 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
237 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
238 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
239 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
240 | } | 241 | } |
241 | else { | 242 | else { |
242 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
243 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
244 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
245 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
246 | } | 247 | } |
247 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
248 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
249 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
250 | if ( temp->getWriteBackFuture() ) | 251 | if ( temp->getWriteBackFuture() ) |
251 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
252 | 253 | ||
253 | if ( action == 1000 ) { | 254 | if ( action == 1000 ) { |
255 | mIsKapiFile = false; | ||
254 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
255 | syncKDE(); | 257 | syncKDE(); |
256 | #else | 258 | #else |
257 | syncSharp(); | 259 | syncSharp(); |
258 | #endif | 260 | #endif |
259 | 261 | ||
260 | } else if ( action == 1001 ) { | 262 | } else if ( action == 1001 ) { |
261 | syncLocalFile(); | 263 | syncLocalFile(); |
262 | 264 | ||
263 | } else if ( action == 1002 ) { | 265 | } else if ( action == 1002 ) { |
264 | mWriteBackFile = false; | 266 | mWriteBackFile = false; |
265 | mAskForPreferences = false; | 267 | mAskForPreferences = false; |
266 | mShowSyncSummary = false; | 268 | mShowSyncSummary = false; |
267 | mSyncAlgoPrefs = 3; | 269 | mSyncAlgoPrefs = 3; |
268 | quickSyncLocalFile(); | 270 | quickSyncLocalFile(); |
269 | 271 | ||
270 | } else if ( action >= 1003 ) { | 272 | } else if ( action >= 1003 ) { |
271 | if ( temp->getIsLocalFileSync() ) { | 273 | if ( temp->getIsLocalFileSync() ) { |
272 | switch(mTargetApp) | 274 | switch(mTargetApp) |
273 | { | 275 | { |
274 | case (KAPI): | 276 | case (KAPI): |
275 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
276 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
277 | break; | 279 | break; |
278 | case (KOPI): | 280 | case (KOPI): |
279 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
280 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
281 | break; | 283 | break; |
282 | case (PWMPI): | 284 | case (PWMPI): |
283 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
285 | break; | 287 | break; |
286 | default: | 288 | default: |
287 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
288 | break; | 290 | break; |
289 | 291 | ||
290 | } | 292 | } |
291 | } else { | 293 | } else { |
292 | if ( temp->getIsPhoneSync() ) { | 294 | if ( temp->getIsPhoneSync() ) { |
293 | mPhoneDevice = temp->getPhoneDevice( ) ; | 295 | mPhoneDevice = temp->getPhoneDevice( ) ; |
294 | mPhoneConnection = temp->getPhoneConnection( ); | 296 | mPhoneConnection = temp->getPhoneConnection( ); |
295 | mPhoneModel = temp->getPhoneModel( ); | 297 | mPhoneModel = temp->getPhoneModel( ); |
296 | syncPhone(); | 298 | syncPhone(); |
297 | } else if ( temp->getIsPiSync() ) { | 299 | } else if ( temp->getIsPiSync() ) { |
298 | if ( mTargetApp == KAPI ) { | 300 | if ( mTargetApp == KAPI ) { |
299 | mPassWordPiSync = temp->getRemotePwAB(); | 301 | mPassWordPiSync = temp->getRemotePwAB(); |
300 | mActiveSyncPort = temp->getRemotePortAB(); | 302 | mActiveSyncPort = temp->getRemotePortAB(); |
301 | mActiveSyncIP = temp->getRemoteIPAB(); | 303 | mActiveSyncIP = temp->getRemoteIPAB(); |
@@ -837,101 +839,119 @@ QString KSyncManager::getPassword( ) | |||
837 | QDialog dia ( mParent, "input-dialog", true ); | 839 | QDialog dia ( mParent, "input-dialog", true ); |
838 | QLineEdit lab ( &dia ); | 840 | QLineEdit lab ( &dia ); |
839 | lab.setEchoMode( QLineEdit::Password ); | 841 | lab.setEchoMode( QLineEdit::Password ); |
840 | QVBoxLayout lay( &dia ); | 842 | QVBoxLayout lay( &dia ); |
841 | lay.setMargin(7); | 843 | lay.setMargin(7); |
842 | lay.setSpacing(7); | 844 | lay.setSpacing(7); |
843 | lay.addWidget( &lab); | 845 | lay.addWidget( &lab); |
844 | dia.setFixedSize( 230,50 ); | 846 | dia.setFixedSize( 230,50 ); |
845 | dia.setCaption( i18n("Enter password") ); | 847 | dia.setCaption( i18n("Enter password") ); |
846 | QPushButton pb ( "OK", &dia); | 848 | QPushButton pb ( "OK", &dia); |
847 | lay.addWidget( &pb ); | 849 | lay.addWidget( &pb ); |
848 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 850 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
849 | dia.show(); | 851 | dia.show(); |
850 | int res = dia.exec(); | 852 | int res = dia.exec(); |
851 | if ( res ) | 853 | if ( res ) |
852 | retfile = lab.text(); | 854 | retfile = lab.text(); |
853 | dia.hide(); | 855 | dia.hide(); |
854 | qApp->processEvents(); | 856 | qApp->processEvents(); |
855 | return retfile; | 857 | return retfile; |
856 | 858 | ||
857 | } | 859 | } |
858 | 860 | ||
859 | 861 | ||
860 | void KSyncManager::confSync() | 862 | void KSyncManager::confSync() |
861 | { | 863 | { |
862 | static KSyncPrefsDialog* sp = 0; | 864 | static KSyncPrefsDialog* sp = 0; |
863 | if ( ! sp ) { | 865 | if ( ! sp ) { |
864 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 866 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
865 | } | 867 | } |
866 | sp->usrReadConfig(); | 868 | sp->usrReadConfig(); |
867 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
868 | sp->showMaximized(); | 870 | sp->showMaximized(); |
869 | #else | 871 | #else |
870 | sp->show(); | 872 | sp->show(); |
871 | #endif | 873 | #endif |
872 | sp->exec(); | 874 | sp->exec(); |
873 | QStringList oldSyncProfileNames = mSyncProfileNames; | 875 | QStringList oldSyncProfileNames = mSyncProfileNames; |
874 | mSyncProfileNames = sp->getSyncProfileNames(); | 876 | mSyncProfileNames = sp->getSyncProfileNames(); |
875 | mLocalMachineName = sp->getLocalMachineName (); | 877 | mLocalMachineName = sp->getLocalMachineName (); |
876 | int ii; | 878 | int ii; |
877 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 879 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
878 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 880 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
879 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 881 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
880 | } | 882 | } |
881 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 883 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
882 | } | 884 | } |
883 | void KSyncManager::syncKDE() | 885 | void KSyncManager::syncKDE() |
884 | { | 886 | { |
887 | mSyncWithDesktop = true; | ||
885 | emit save(); | 888 | emit save(); |
886 | switch(mTargetApp) | 889 | switch(mTargetApp) |
887 | { | 890 | { |
888 | case (KAPI): | 891 | case (KAPI): |
889 | 892 | { | |
893 | #ifdef DESKTOP_VERSION | ||
894 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | ||
895 | #else | ||
896 | QString command = "kdeabdump"; | ||
897 | #endif | ||
898 | if ( ! QFile::exists ( command ) ) | ||
899 | command = "kdeabdump"; | ||
900 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | ||
901 | system ( command.latin1()); | ||
902 | if ( syncWithFile( fileName,true ) ) { | ||
903 | if ( mWriteBackFile ) { | ||
904 | command += " --read"; | ||
905 | system ( command.latin1()); | ||
906 | } | ||
907 | } | ||
908 | |||
909 | } | ||
890 | break; | 910 | break; |
891 | case (KOPI): | 911 | case (KOPI): |
892 | { | 912 | { |
893 | #ifdef DESKTOP_VERSION | 913 | #ifdef DESKTOP_VERSION |
894 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 914 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
895 | #else | 915 | #else |
896 | QString command = "kdecaldump"; | 916 | QString command = "kdecaldump"; |
897 | #endif | 917 | #endif |
898 | if ( ! QFile::exists ( command ) ) | 918 | if ( ! QFile::exists ( command ) ) |
899 | command = "kdecaldump"; | 919 | command = "kdecaldump"; |
900 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 920 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
901 | system ( command.latin1()); | 921 | system ( command.latin1()); |
902 | if ( syncWithFile( fileName,true ) ) { | 922 | if ( syncWithFile( fileName,true ) ) { |
903 | if ( mWriteBackFile ) { | 923 | if ( mWriteBackFile ) { |
904 | command += " --read"; | 924 | command += " --read"; |
905 | system ( command.latin1()); | 925 | system ( command.latin1()); |
906 | } | 926 | } |
907 | } | 927 | } |
908 | 928 | ||
909 | } | 929 | } |
910 | break; | 930 | break; |
911 | case (PWMPI): | 931 | case (PWMPI): |
912 | 932 | ||
913 | break; | 933 | break; |
914 | default: | 934 | default: |
915 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 935 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
916 | break; | 936 | break; |
917 | 937 | ||
918 | } | 938 | } |
919 | } | 939 | } |
920 | 940 | ||
921 | void KSyncManager::syncSharp() | 941 | void KSyncManager::syncSharp() |
922 | { | 942 | { |
923 | 943 | ||
924 | if ( ! syncExternalApplication("sharp") ) | 944 | if ( ! syncExternalApplication("sharp") ) |
925 | qDebug("ERROR sync sharp "); | 945 | qDebug("ERROR sync sharp "); |
926 | } | 946 | } |
927 | 947 | ||
928 | bool KSyncManager::syncExternalApplication(QString resource) | 948 | bool KSyncManager::syncExternalApplication(QString resource) |
929 | { | 949 | { |
930 | 950 | ||
931 | emit save(); | 951 | emit save(); |
932 | 952 | ||
933 | if ( mAskForPreferences ) | 953 | if ( mAskForPreferences ) |
934 | if ( !edit_sync_options()) { | 954 | if ( !edit_sync_options()) { |
935 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 955 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
936 | return false; | 956 | return false; |
937 | } | 957 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 2af891b..6da0ee4 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -77,138 +77,140 @@ class KCommandSocket : public QObject | |||
77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
79 | void readFile( QString ); | 79 | void readFile( QString ); |
80 | void writeFile( QString ); | 80 | void writeFile( QString ); |
81 | void sendStop(); | 81 | void sendStop(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void commandFinished( KCommandSocket*, int ); | 84 | void commandFinished( KCommandSocket*, int ); |
85 | private slots: | 85 | private slots: |
86 | void startReadFileFromSocket(); | 86 | void startReadFileFromSocket(); |
87 | void readFileFromSocket(); | 87 | void readFileFromSocket(); |
88 | void deleteSocket(); | 88 | void deleteSocket(); |
89 | void writeFileToSocket(); | 89 | void writeFileToSocket(); |
90 | private : | 90 | private : |
91 | QSocket* mSocket; | 91 | QSocket* mSocket; |
92 | QString mPassWord; | 92 | QString mPassWord; |
93 | Q_UINT16 mPort; | 93 | Q_UINT16 mPort; |
94 | QString mHost; | 94 | QString mHost; |
95 | QString mFileName; | 95 | QString mFileName; |
96 | QTimer* mTimerSocket; | 96 | QTimer* mTimerSocket; |
97 | int mRetVal; | 97 | int mRetVal; |
98 | QTime mTime; | 98 | QTime mTime; |
99 | QString mFileString; | 99 | QString mFileString; |
100 | bool mFirst; | 100 | bool mFirst; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | class KSyncManager : public QObject | 104 | class KSyncManager : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | enum TargetApp { | 109 | enum TargetApp { |
110 | KOPI = 0, | 110 | KOPI = 0, |
111 | KAPI = 1, | 111 | KAPI = 1, |
112 | PWMPI = 2 }; | 112 | PWMPI = 2 }; |
113 | 113 | ||
114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
115 | ~KSyncManager() ; | 115 | ~KSyncManager() ; |
116 | 116 | ||
117 | void multiSync( bool askforPrefs ); | 117 | void multiSync( bool askforPrefs ); |
118 | bool blockSave() { return mBlockSaveFlag; } | 118 | bool blockSave() { return mBlockSaveFlag; } |
119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
120 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 120 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
121 | QString defaultFileName() { return mDefFileName ;} | 121 | QString defaultFileName() { return mDefFileName ;} |
122 | QString syncFileName(); | 122 | QString syncFileName(); |
123 | void enableQuick( bool ask = true); | 123 | void enableQuick( bool ask = true); |
124 | 124 | ||
125 | bool syncWithDesktop () { return mSyncWithDesktop;} | ||
125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 126 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
126 | QString getCurrentSyncName() { return mCurrentSyncName; } | 127 | QString getCurrentSyncName() { return mCurrentSyncName; } |
127 | 128 | ||
128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 129 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
129 | void hideProgressBar(); | 130 | void hideProgressBar(); |
130 | bool isProgressBarCanceled(); | 131 | bool isProgressBarCanceled(); |
131 | 132 | ||
132 | // sync stuff | 133 | // sync stuff |
133 | QString mLocalMachineName; | 134 | QString mLocalMachineName; |
134 | QStringList mExternSyncProfiles; | 135 | QStringList mExternSyncProfiles; |
135 | QStringList mSyncProfileNames; | 136 | QStringList mSyncProfileNames; |
136 | bool mAskForPreferences; | 137 | bool mAskForPreferences; |
137 | bool mShowSyncSummary; | 138 | bool mShowSyncSummary; |
138 | bool mIsKapiFile; | 139 | bool mIsKapiFile; |
139 | bool mWriteBackExistingOnly; | 140 | bool mWriteBackExistingOnly; |
140 | int mSyncAlgoPrefs; | 141 | int mSyncAlgoPrefs; |
141 | bool mWriteBackFile; | 142 | bool mWriteBackFile; |
142 | int mWriteBackInFuture; | 143 | int mWriteBackInFuture; |
143 | QString mPhoneDevice; | 144 | QString mPhoneDevice; |
144 | QString mPhoneConnection; | 145 | QString mPhoneConnection; |
145 | QString mPhoneModel; | 146 | QString mPhoneModel; |
146 | QString mPassWordPiSync; | 147 | QString mPassWordPiSync; |
147 | QString mActiveSyncPort; | 148 | QString mActiveSyncPort; |
148 | QString mActiveSyncIP ; | 149 | QString mActiveSyncIP ; |
149 | static QDateTime mRequestedSyncEvent; | 150 | static QDateTime mRequestedSyncEvent; |
150 | 151 | ||
151 | signals: | 152 | signals: |
152 | void save(); | 153 | void save(); |
153 | void request_file(); | 154 | void request_file(); |
154 | void getFile( bool ); | 155 | void getFile( bool ); |
155 | 156 | ||
156 | public slots: | 157 | public slots: |
157 | void slotSyncMenu( int ); | 158 | void slotSyncMenu( int ); |
158 | void slotClearMenu( int action ); | 159 | void slotClearMenu( int action ); |
159 | void deleteCommandSocket(KCommandSocket*s, int state); | 160 | void deleteCommandSocket(KCommandSocket*s, int state); |
160 | void readFileFromSocket(); | 161 | void readFileFromSocket(); |
161 | void fillSyncMenu(); | 162 | void fillSyncMenu(); |
162 | 163 | ||
163 | private: | 164 | private: |
164 | void syncPi(); | 165 | void syncPi(); |
165 | KServerSocket * mServerSocket; | 166 | KServerSocket * mServerSocket; |
166 | KPimPrefs* mPrefs; | 167 | KPimPrefs* mPrefs; |
167 | QString mDefFileName; | 168 | QString mDefFileName; |
168 | QString mCurrentSyncDevice; | 169 | QString mCurrentSyncDevice; |
169 | QString mCurrentSyncName; | 170 | QString mCurrentSyncName; |
170 | void quickSyncLocalFile(); | 171 | void quickSyncLocalFile(); |
171 | bool syncWithFile( QString fn , bool quick ); | 172 | bool syncWithFile( QString fn , bool quick ); |
172 | void syncLocalFile(); | 173 | void syncLocalFile(); |
173 | void syncPhone(); | 174 | void syncPhone(); |
174 | void syncSharp(); | 175 | void syncSharp(); |
175 | void syncKDE(); | 176 | void syncKDE(); |
176 | bool syncExternalApplication(QString); | 177 | bool syncExternalApplication(QString); |
177 | int mCurrentSyncProfile ; | 178 | int mCurrentSyncProfile ; |
178 | void syncRemote( KSyncProfile* prof, bool ask = true); | 179 | void syncRemote( KSyncProfile* prof, bool ask = true); |
179 | bool edit_sync_options(); | 180 | bool edit_sync_options(); |
180 | bool edit_pisync_options(); | 181 | bool edit_pisync_options(); |
181 | int ringSync(); | 182 | int ringSync(); |
182 | QString getPassword( ); | 183 | QString getPassword( ); |
183 | bool mPisyncFinished; | 184 | bool mPisyncFinished; |
184 | bool mBlockSaveFlag; | 185 | bool mBlockSaveFlag; |
185 | QWidget* mParent; | 186 | QWidget* mParent; |
186 | KSyncInterface* mImplementation; | 187 | KSyncInterface* mImplementation; |
187 | TargetApp mTargetApp; | 188 | TargetApp mTargetApp; |
188 | QPopupMenu* mSyncMenu; | 189 | QPopupMenu* mSyncMenu; |
189 | QProgressBar* bar; | 190 | QProgressBar* bar; |
191 | bool mSyncWithDesktop; | ||
190 | 192 | ||
191 | private slots: | 193 | private slots: |
192 | void confSync(); | 194 | void confSync(); |
193 | 195 | ||
194 | 196 | ||
195 | }; | 197 | }; |
196 | 198 | ||
197 | 199 | ||
198 | class KSyncInterface | 200 | class KSyncInterface |
199 | { | 201 | { |
200 | public : | 202 | public : |
201 | virtual void removeSyncInfo( QString syncProfile) = 0; | 203 | virtual void removeSyncInfo( QString syncProfile) = 0; |
202 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 204 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
203 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 205 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
204 | { | 206 | { |
205 | // empty implementation, because some syncable applications do not | 207 | // empty implementation, because some syncable applications do not |
206 | // have an external(sharpdtm) syncmode, like pwmanager. | 208 | // have an external(sharpdtm) syncmode, like pwmanager. |
207 | return false; | 209 | return false; |
208 | } | 210 | } |
209 | 211 | ||
210 | 212 | ||
211 | }; | 213 | }; |
212 | 214 | ||
213 | 215 | ||
214 | #endif | 216 | #endif |