summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-11-25 22:51:38 (UTC)
committer zautrix <zautrix>2005-11-25 22:51:38 (UTC)
commit0e18027f386280bf427ef9d0ffec61a5516cebda (patch) (unidiff)
tree91f93d724d141b9f087e4cef0c1a11e354ee389a /korganizer
parentb71ee5442df23bb9900d3db6e6244773ee34ef13 (diff)
downloadkdepimpi-0e18027f386280bf427ef9d0ffec61a5516cebda.zip
kdepimpi-0e18027f386280bf427ef9d0ffec61a5516cebda.tar.gz
kdepimpi-0e18027f386280bf427ef9d0ffec61a5516cebda.tar.bz2
sync
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 6128137..538325e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1816,193 +1816,193 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1816 while ( inL ) { 1816 while ( inL ) {
1817 1817
1818 qApp->processEvents(); 1818 qApp->processEvents();
1819 if ( ! bar.isVisible() ) 1819 if ( ! bar.isVisible() )
1820 return false; 1820 return false;
1821 if ( incCounter % modulo == 0 ) 1821 if ( incCounter % modulo == 0 )
1822 bar.setProgress( incCounter ); 1822 bar.setProgress( incCounter );
1823 ++incCounter; 1823 ++incCounter;
1824 uid = inL->uid(); 1824 uid = inL->uid();
1825 bool skipIncidence = false; 1825 bool skipIncidence = false;
1826 if ( uid.left(15) == QString("last-syncEvent-") ) 1826 if ( uid.left(15) == QString("last-syncEvent-") )
1827 skipIncidence = true; 1827 skipIncidence = true;
1828 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1828 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1829 skipIncidence = true; 1829 skipIncidence = true;
1830 if ( !skipIncidence ) { 1830 if ( !skipIncidence ) {
1831 inR = remote->incidenceForUid( uid , true ); 1831 inR = remote->incidenceForUid( uid , true );
1832 if ( ! inR ) { 1832 if ( ! inR ) {
1833 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1833 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1834 // no conflict ********** add or delete local 1834 // no conflict ********** add or delete local
1835 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1835 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1836 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1836 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1837 checkExternSyncEvent(eventLSyncSharp, inL); 1837 checkExternSyncEvent(eventLSyncSharp, inL);
1838 local->deleteIncidence( inL ); 1838 local->deleteIncidence( inL );
1839 ++deletedEventL; 1839 ++deletedEventL;
1840 } else { 1840 } else {
1841 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1841 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1842 inL->removeID(mCurrentSyncDevice ); 1842 inL->removeID(mCurrentSyncDevice );
1843 ++addedEventR; 1843 ++addedEventR;
1844 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1844 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1845 inL->setLastModified( modifiedCalendar ); 1845 inL->setLastModified( modifiedCalendar );
1846 inR = inL->clone(); 1846 inR = inL->clone();
1847 inR->setIDStr( ":" ); 1847 inR->setIDStr( ":" );
1848 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1848 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1849 inR->setCalID( 0 );// add to default cal 1849 inR->setCalID( 0 );// add to default cal
1850 remote->addIncidence( inR ); 1850 remote->addIncidence( inR );
1851 } 1851 }
1852 } 1852 }
1853 } else { 1853 } else {
1854 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1854 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1855 checkExternSyncEvent(eventLSyncSharp, inL); 1855 checkExternSyncEvent(eventLSyncSharp, inL);
1856 local->deleteIncidence( inL ); 1856 local->deleteIncidence( inL );
1857 ++deletedEventL; 1857 ++deletedEventL;
1858 } else { 1858 } else {
1859 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1859 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1860 ++addedEventR; 1860 ++addedEventR;
1861 inL->setLastModified( modifiedCalendar ); 1861 inL->setLastModified( modifiedCalendar );
1862 inR = inL->clone(); 1862 inR = inL->clone();
1863 inR->setIDStr( ":" ); 1863 inR->setIDStr( ":" );
1864 inR->setCalID( 0 );// add to default cal 1864 inR->setCalID( 0 );// add to default cal
1865 remote->addIncidence( inR ); 1865 remote->addIncidence( inR );
1866 } 1866 }
1867 } 1867 }
1868 } 1868 }
1869 } else { 1869 } else {
1870 ++filteredOUT; 1870 ++filteredOUT;
1871 } 1871 }
1872 } 1872 }
1873 } 1873 }
1874 inL = el.next(); 1874 inL = el.next();
1875 } 1875 }
1876 int delFut = 0; 1876 int delFut = 0;
1877 int remRem = 0; 1877 int remRem = 0;
1878 if ( mSyncManager->mWriteBackInFuture ) { 1878 if ( mSyncManager->mWriteBackInFuture ) {
1879 er = remote->rawIncidences(); 1879 er = remote->rawIncidences();
1880 remRem = er.count(); 1880 remRem = er.count();
1881 inR = er.first(); 1881 inR = er.first();
1882 QDateTime dt; 1882 QDateTime dt;
1883 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1883 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1884 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1884 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1885 while ( inR ) { 1885 while ( inR ) {
1886 if ( inR->typeID() == todoID ) { 1886 if ( inR->typeID() == todoID ) {
1887 Todo * t = (Todo*)inR; 1887 Todo * t = (Todo*)inR;
1888 if ( t->hasDueDate() ) 1888 if ( t->hasDueDate() )
1889 dt = t->dtDue(); 1889 dt = t->dtDue();
1890 else 1890 else
1891 dt = cur.addSecs( 62 ); 1891 dt = cur.addSecs( 62 );
1892 } 1892 }
1893 else if (inR->typeID() == eventID ) { 1893 else if (inR->typeID() == eventID ) {
1894 bool ok; 1894 bool ok;
1895 dt = inR->getNextOccurence( cur, &ok ); 1895 dt = inR->getNextOccurence( cur, &ok );
1896 if ( !ok ) 1896 if ( !ok )
1897 dt = cur.addSecs( -62 ); 1897 dt = cur.addSecs( -62 );
1898 } 1898 }
1899 else 1899 else
1900 dt = inR->dtStart(); 1900 dt = inR->dtStart();
1901 if ( dt < cur || dt > end ) { 1901 if ( dt < cur || dt > end ) {
1902 remote->deleteIncidence( inR ); 1902 remote->deleteIncidence( inR );
1903 ++delFut; 1903 ++delFut;
1904 } 1904 }
1905 inR = er.next(); 1905 inR = er.next();
1906 } 1906 }
1907 } 1907 }
1908 bar.hide(); 1908 bar.hide();
1909 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1909 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1910 if ( mMultiResourceSync ) { 1910 if ( mMultiResourceSync ) {
1911 remote->removeSyncInfo( "" ); //all 1911 remote->removeSyncInfo( "" ); //all
1912 1912 qDebug("KO: Remoing all sync info on remote ");
1913 } else { 1913 } else {
1914 eventLSync->setReadOnly( false ); 1914 eventLSync->setReadOnly( false );
1915 eventLSync->setDtStart( mLastCalendarSync ); 1915 eventLSync->setDtStart( mLastCalendarSync );
1916 eventRSync->setDtStart( mLastCalendarSync ); 1916 eventRSync->setDtStart( mLastCalendarSync );
1917 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1917 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1919 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1919 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1920 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1920 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1921 eventLSync->setReadOnly( true ); 1921 eventLSync->setReadOnly( true );
1922 } 1922 }
1923 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1923 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1924 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... 1924 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal...
1925 remote->addEvent( eventRSync ); 1925 remote->addEvent( eventRSync );
1926 else 1926 else
1927 delete eventRSync; 1927 delete eventRSync;
1928 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1928 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1929 QString mes; 1929 QString mes;
1930 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1930 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1931 QString delmess; 1931 QString delmess;
1932 if ( delFut ) { 1932 if ( delFut ) {
1933 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1933 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1934 mes += delmess; 1934 mes += delmess;
1935 } 1935 }
1936 mes = i18n("Local calendar changed!\n") +mes; 1936 mes = i18n("Local calendar changed!\n") +mes;
1937 mCalendar->checkAlarmForIncidence( 0, true ); 1937 mCalendar->checkAlarmForIncidence( 0, true );
1938 qDebug( mes ); 1938 qDebug( mes );
1939 if ( mSyncManager->mShowSyncSummary ) { 1939 if ( mSyncManager->mShowSyncSummary ) {
1940 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1940 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1941 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1941 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1942 qDebug("KO: WB cancelled "); 1942 qDebug("KO: WB cancelled ");
1943 mSyncManager->mWriteBackFile = false; 1943 mSyncManager->mWriteBackFile = false;
1944 return syncOK; 1944 return syncOK;
1945 } 1945 }
1946 } 1946 }
1947 return syncOK; 1947 return syncOK;
1948} 1948}
1949 1949
1950void CalendarView::setSyncDevice( QString s ) 1950void CalendarView::setSyncDevice( QString s )
1951{ 1951{
1952 mCurrentSyncDevice= s; 1952 mCurrentSyncDevice= s;
1953} 1953}
1954void CalendarView::setSyncName( QString s ) 1954void CalendarView::setSyncName( QString s )
1955{ 1955{
1956 mCurrentSyncName= s; 1956 mCurrentSyncName= s;
1957} 1957}
1958bool CalendarView::syncCalendar(QString filename, int mode) 1958bool CalendarView::syncCalendar(QString filename, int mode)
1959{ 1959{
1960 //qDebug("syncCalendar %s ", filename.latin1()); 1960 //qDebug("syncCalendar %s ", filename.latin1());
1961 mGlobalSyncMode = SYNC_MODE_NORMAL; 1961 mGlobalSyncMode = SYNC_MODE_NORMAL;
1962 CalendarLocal* calendar = new CalendarLocal(); 1962 CalendarLocal* calendar = new CalendarLocal();
1963 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1963 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1964 FileStorage* storage = new FileStorage( calendar ); 1964 FileStorage* storage = new FileStorage( calendar );
1965 bool syncOK = false; 1965 bool syncOK = false;
1966 storage->setFileName( filename ); 1966 storage->setFileName( filename );
1967 // qDebug("loading ... "); 1967 // qDebug("loading ... ");
1968 if ( storage->load() ) { 1968 if ( storage->load() ) {
1969 getEventViewerDialog()->setSyncMode( true ); 1969 getEventViewerDialog()->setSyncMode( true );
1970 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1970 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1971 getEventViewerDialog()->setSyncMode( false ); 1971 getEventViewerDialog()->setSyncMode( false );
1972 if ( syncOK ) { 1972 if ( syncOK ) {
1973 if ( mSyncManager->mWriteBackFile ) 1973 if ( mSyncManager->mWriteBackFile )
1974 { 1974 {
1975 storage->setSaveFormat( new ICalFormat() ); 1975 storage->setSaveFormat( new ICalFormat() );
1976 storage->save(); 1976 storage->save();
1977 } 1977 }
1978 } 1978 }
1979 setModified( true ); 1979 setModified( true );
1980 } 1980 }
1981 delete storage; 1981 delete storage;
1982 delete calendar; 1982 delete calendar;
1983 if ( syncOK ) 1983 if ( syncOK )
1984 updateView(); 1984 updateView();
1985 return syncOK; 1985 return syncOK;
1986} 1986}
1987 1987
1988void CalendarView::syncExternal( int mode ) 1988void CalendarView::syncExternal( int mode )
1989{ 1989{
1990 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1990 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1991 qApp->processEvents(); 1991 qApp->processEvents();
1992 CalendarLocal* calendar = new CalendarLocal(); 1992 CalendarLocal* calendar = new CalendarLocal();
1993 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1993 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1994 bool syncOK = false; 1994 bool syncOK = false;
1995 bool loadSuccess = false; 1995 bool loadSuccess = false;
1996 PhoneFormat* phoneFormat = 0; 1996 PhoneFormat* phoneFormat = 0;
1997 emit tempDisableBR(true); 1997 emit tempDisableBR(true);
1998#ifndef DESKTOP_VERSION 1998#ifndef DESKTOP_VERSION
1999 SharpFormat* sharpFormat = 0; 1999 SharpFormat* sharpFormat = 0;
2000 if ( mode == 0 ) { // sharp 2000 if ( mode == 0 ) { // sharp
2001 sharpFormat = new SharpFormat () ; 2001 sharpFormat = new SharpFormat () ;
2002 loadSuccess = sharpFormat->load( calendar, mCalendar ); 2002 loadSuccess = sharpFormat->load( calendar, mCalendar );
2003 2003
2004 } else 2004 } else
2005#endif 2005#endif
2006 if ( mode == 1 ) { // phone 2006 if ( mode == 1 ) { // phone
2007 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 2007 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
2008 mSyncManager->mPhoneDevice, 2008 mSyncManager->mPhoneDevice,