summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--libkcal/calendar.h2
-rw-r--r--libkcal/calendarlocal.cpp11
-rw-r--r--libkcal/calendarlocal.h2
4 files changed, 14 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 538325e..9571f16 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1625,303 +1625,303 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1625 mLastCalendarSync = QDateTime::currentDateTime(); 1625 mLastCalendarSync = QDateTime::currentDateTime();
1626 if ( mSyncManager->syncWithDesktop() ) { 1626 if ( mSyncManager->syncWithDesktop() ) {
1627 remote->resetPilotStat(1); 1627 remote->resetPilotStat(1);
1628 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1628 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1629 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1629 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1630 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1630 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1631 } else { 1631 } else {
1632 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1632 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1633 } 1633 }
1634 } 1634 }
1635 QDateTime modifiedCalendar = mLastCalendarSync; 1635 QDateTime modifiedCalendar = mLastCalendarSync;
1636 eventLSync = getLastSyncEvent(); 1636 eventLSync = getLastSyncEvent();
1637 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1637 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1638 if ( eventR ) { 1638 if ( eventR ) {
1639 qDebug("KO: Last-syncEvent on remote found "); 1639 qDebug("KO: Last-syncEvent on remote found ");
1640 eventRSync = (Event*) eventR->clone(); 1640 eventRSync = (Event*) eventR->clone();
1641 remote->deleteEvent(eventR ); 1641 remote->deleteEvent(eventR );
1642 1642
1643 } else { 1643 } else {
1644 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1644 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1645 eventRSync = (Event*)eventLSync->clone(); 1645 eventRSync = (Event*)eventLSync->clone();
1646 } else { 1646 } else {
1647 fullDateRange = true; 1647 fullDateRange = true;
1648 eventRSync = new Event(); 1648 eventRSync = new Event();
1649 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1649 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1650 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1650 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1651 eventRSync->setDtStart( mLastCalendarSync ); 1651 eventRSync->setDtStart( mLastCalendarSync );
1652 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1652 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1653 eventRSync->setCategories( i18n("SyncEvent") ); 1653 eventRSync->setCategories( i18n("SyncEvent") );
1654 } 1654 }
1655 } 1655 }
1656 if ( eventLSync->dtStart() == mLastCalendarSync ) 1656 if ( eventLSync->dtStart() == mLastCalendarSync )
1657 fullDateRange = true; 1657 fullDateRange = true;
1658 1658
1659 if ( ! fullDateRange ) { 1659 if ( ! fullDateRange ) {
1660 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1660 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1661 1661
1662 qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1662 qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1663 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1663 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1664 fullDateRange = true; 1664 fullDateRange = true;
1665 } 1665 }
1666 } 1666 }
1667 if ( mSyncManager->syncWithDesktop() ) { 1667 if ( mSyncManager->syncWithDesktop() ) {
1668 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1668 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1669 } 1669 }
1670 if ( fullDateRange ) 1670 if ( fullDateRange )
1671 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1671 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1672 else 1672 else
1673 mLastCalendarSync = eventLSync->dtStart(); 1673 mLastCalendarSync = eventLSync->dtStart();
1674 // for resyncing if own file has changed 1674 // for resyncing if own file has changed
1675 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1675 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1676 mLastCalendarSync = loadedFileVersion; 1676 mLastCalendarSync = loadedFileVersion;
1677 //qDebug("setting mLastCalendarSync "); 1677 //qDebug("setting mLastCalendarSync ");
1678 } 1678 }
1679 //qDebug("*************************** "); 1679 //qDebug("*************************** ");
1680 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1680 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1681 QPtrList<Incidence> er = remote->rawIncidences(); 1681 QPtrList<Incidence> er = remote->rawIncidences();
1682 Incidence* inR = er.first(); 1682 Incidence* inR = er.first();
1683 Incidence* inL; 1683 Incidence* inL;
1684 QProgressBar bar( er.count(),0 ); 1684 QProgressBar bar( er.count(),0 );
1685 bar.setCaption (i18n("Syncing - close to abort!") ); 1685 bar.setCaption (i18n("Syncing - close to abort!") );
1686 1686
1687 // ************** setting up filter ************* 1687 // ************** setting up filter *************
1688 CalFilter *filterIN = 0; 1688 CalFilter *filterIN = 0;
1689 CalFilter *filterOUT = 0; 1689 CalFilter *filterOUT = 0;
1690 CalFilter *filter = mFilters.first(); 1690 CalFilter *filter = mFilters.first();
1691 while(filter) { 1691 while(filter) {
1692 if ( filter->name() == mSyncManager->mFilterInCal ) 1692 if ( filter->name() == mSyncManager->mFilterInCal )
1693 filterIN = filter; 1693 filterIN = filter;
1694 if ( filter->name() == mSyncManager->mFilterOutCal ) 1694 if ( filter->name() == mSyncManager->mFilterOutCal )
1695 filterOUT = filter; 1695 filterOUT = filter;
1696 filter = mFilters.next(); 1696 filter = mFilters.next();
1697 } 1697 }
1698 int w = 300; 1698 int w = 300;
1699 if ( QApplication::desktop()->width() < 320 ) 1699 if ( QApplication::desktop()->width() < 320 )
1700 w = 220; 1700 w = 220;
1701 int h = bar.sizeHint().height() ; 1701 int h = bar.sizeHint().height() ;
1702 int dw = QApplication::desktop()->width(); 1702 int dw = QApplication::desktop()->width();
1703 int dh = QApplication::desktop()->height(); 1703 int dh = QApplication::desktop()->height();
1704 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1704 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1705 bar.show(); 1705 bar.show();
1706 int modulo = (er.count()/10)+1; 1706 int modulo = (er.count()/10)+1;
1707 int incCounter = 0; 1707 int incCounter = 0;
1708 while ( inR ) { 1708 while ( inR ) {
1709 if ( ! bar.isVisible() ) 1709 if ( ! bar.isVisible() )
1710 return false; 1710 return false;
1711 if ( incCounter % modulo == 0 ) 1711 if ( incCounter % modulo == 0 )
1712 bar.setProgress( incCounter ); 1712 bar.setProgress( incCounter );
1713 ++incCounter; 1713 ++incCounter;
1714 uid = inR->uid(); 1714 uid = inR->uid();
1715 bool skipIncidence = false; 1715 bool skipIncidence = false;
1716 if ( uid.left(15) == QString("last-syncEvent-") ) 1716 if ( uid.left(15) == QString("last-syncEvent-") )
1717 skipIncidence = true; 1717 skipIncidence = true;
1718 QString idS; 1718 QString idS;
1719 qApp->processEvents(); 1719 qApp->processEvents();
1720 if ( !skipIncidence ) { 1720 if ( !skipIncidence ) {
1721 inL = local->incidenceForUid( uid , false ); 1721 inL = local->incidenceForUid( uid , false , true );
1722 if ( inL ) { // maybe conflict - same uid in both calendars 1722 if ( inL ) { // maybe conflict - same uid in both calendars
1723 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1723 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1724 //qDebug("take %d %s ", take, inL->summary().latin1()); 1724 //qDebug("take %d %s ", take, inL->summary().latin1());
1725 if ( take == 3 ) 1725 if ( take == 3 )
1726 return false; 1726 return false;
1727 if ( take == 1 ) {// take local ********************** 1727 if ( take == 1 ) {// take local **********************
1728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1729 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1729 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1730 else 1730 else
1731 idS = inR->IDStr(); 1731 idS = inR->IDStr();
1732 int calID = inR->calID(); 1732 int calID = inR->calID();
1733 remote->deleteIncidence( inR ); 1733 remote->deleteIncidence( inR );
1734 inR = inL->clone(); 1734 inR = inL->clone();
1735 inR->setCalID( calID ); 1735 inR->setCalID( calID );
1736 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1736 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1737 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1737 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1738 inR->setIDStr( idS ); 1738 inR->setIDStr( idS );
1739 remote->addIncidence( inR ); 1739 remote->addIncidence( inR );
1740 if ( mSyncManager->syncWithDesktop() ) 1740 if ( mSyncManager->syncWithDesktop() )
1741 inR->setPilotId( 2 ); 1741 inR->setPilotId( 2 );
1742 ++changedRemote; 1742 ++changedRemote;
1743 } else {// take remote ********************** 1743 } else {// take remote **********************
1744 if ( !inL->isReadOnly() ) { 1744 if ( !inL->isReadOnly() ) {
1745 idS = inL->IDStr(); 1745 idS = inL->IDStr();
1746 int pid = inL->pilotId(); 1746 int pid = inL->pilotId();
1747 int calID = inL->calID(); 1747 int calID = inL->calID();
1748 local->deleteIncidence( inL ); 1748 local->deleteIncidence( inL );
1749 inL = inR->clone(); 1749 inL = inR->clone();
1750 inL->setCalID( calID ); 1750 inL->setCalID( calID );
1751 if ( mSyncManager->syncWithDesktop() ) 1751 if ( mSyncManager->syncWithDesktop() )
1752 inL->setPilotId( pid ); 1752 inL->setPilotId( pid );
1753 inL->setIDStr( idS ); 1753 inL->setIDStr( idS );
1754 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1754 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1755 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1755 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1756 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1756 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1757 } 1757 }
1758 local->addIncidence( inL ); 1758 local->addIncidence( inL );
1759 ++changedLocal; 1759 ++changedLocal;
1760 } 1760 }
1761 } 1761 }
1762 } 1762 }
1763 } else { // no conflict ********** add or delete remote 1763 } else { // no conflict ********** add or delete remote
1764 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1764 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1765 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1765 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1766 QString des = eventLSync->description(); 1766 QString des = eventLSync->description();
1767 QString pref = "e"; 1767 QString pref = "e";
1768 if ( inR->typeID() == todoID ) 1768 if ( inR->typeID() == todoID )
1769 pref = "t"; 1769 pref = "t";
1770 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1770 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1771 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1771 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1772 //remote->deleteIncidence( inR ); 1772 //remote->deleteIncidence( inR );
1773 ++deletedEventR; 1773 ++deletedEventR;
1774 } else { 1774 } else {
1775 inR->setLastModified( modifiedCalendar ); 1775 inR->setLastModified( modifiedCalendar );
1776 inL = inR->clone(); 1776 inL = inR->clone();
1777 inL->setIDStr( ":" ); 1777 inL->setIDStr( ":" );
1778 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1778 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1779 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1779 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1780 1780
1781 inL->setCalID( 0 );// add to default cal 1781 inL->setCalID( 0 );// add to default cal
1782 local->addIncidence( inL ); 1782 local->addIncidence( inL );
1783 ++addedEvent; 1783 ++addedEvent;
1784 1784
1785 } 1785 }
1786 } else { 1786 } else {
1787 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1787 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1788 inR->setLastModified( modifiedCalendar ); 1788 inR->setLastModified( modifiedCalendar );
1789 inL = inR->clone(); 1789 inL = inR->clone();
1790 inL->setIDStr( ":" ); 1790 inL->setIDStr( ":" );
1791 inL->setCalID( 0 );// add to default cal 1791 inL->setCalID( 0 );// add to default cal
1792 local->addIncidence( inL ); 1792 local->addIncidence( inL );
1793 ++addedEvent; 1793 ++addedEvent;
1794 1794
1795 } else { 1795 } else {
1796 checkExternSyncEvent(eventRSyncSharp, inR); 1796 checkExternSyncEvent(eventRSyncSharp, inR);
1797 remote->deleteIncidence( inR ); 1797 remote->deleteIncidence( inR );
1798 ++deletedEventR; 1798 ++deletedEventR;
1799 } 1799 }
1800 } 1800 }
1801 } else { 1801 } else {
1802 ++filteredIN; 1802 ++filteredIN;
1803 } 1803 }
1804 } 1804 }
1805 } 1805 }
1806 inR = er.next(); 1806 inR = er.next();
1807 } 1807 }
1808 QPtrList<Incidence> el = local->rawIncidences(); 1808 QPtrList<Incidence> el = local->rawIncidences();
1809 inL = el.first(); 1809 inL = el.first();
1810 modulo = (el.count()/10)+1; 1810 modulo = (el.count()/10)+1;
1811 bar.setCaption (i18n("Add / remove events") ); 1811 bar.setCaption (i18n("Add / remove events") );
1812 bar.setTotalSteps ( el.count() ) ; 1812 bar.setTotalSteps ( el.count() ) ;
1813 bar.show(); 1813 bar.show();
1814 incCounter = 0; 1814 incCounter = 0;
1815 1815
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, 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 qDebug("KO: Remoing all sync info on remote "); 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;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 66836a1..f301768 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,176 +1,176 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual bool mergeCalendarFile( QString name ) = 0; 79 virtual bool mergeCalendarFile( QString name ) = 0;
80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; 80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ) = 0;
81 virtual void setSyncEventsReadOnly() = 0; 81 virtual void setSyncEventsReadOnly() = 0;
82 virtual void setSyncEventsEnabled() = 0; 82 virtual void setSyncEventsEnabled() = 0;
83 virtual void stopAllTodos() = 0; 83 virtual void stopAllTodos() = 0;
84 virtual void clearUndo( Incidence * newUndo ); 84 virtual void clearUndo( Incidence * newUndo );
85 85
86 /** 86 /**
87 Sync changes in memory to persistant storage. 87 Sync changes in memory to persistant storage.
88 */ 88 */
89 virtual void save() = 0; 89 virtual void save() = 0;
90 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 90 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
91 virtual void removeSyncInfo( QString syncProfile) = 0; 91 virtual void removeSyncInfo( QString syncProfile) = 0;
92 virtual bool isSaving() { return false; } 92 virtual bool isSaving() { return false; }
93 93
94 /** 94 /**
95 Return the owner of the calendar's full name. 95 Return the owner of the calendar's full name.
96 */ 96 */
97 const QString &getOwner() const; 97 const QString &getOwner() const;
98 /** 98 /**
99 Set the owner of the calendar. Should be owner's full name. 99 Set the owner of the calendar. Should be owner's full name.
100 */ 100 */
101 void setOwner( const QString &os ); 101 void setOwner( const QString &os );
102 /** 102 /**
103 Return the email address of the calendar owner. 103 Return the email address of the calendar owner.
104 */ 104 */
105 const QString &getEmail(); 105 const QString &getEmail();
106 /** 106 /**
107 Set the email address of the calendar owner. 107 Set the email address of the calendar owner.
108 */ 108 */
109 void setEmail( const QString & ); 109 void setEmail( const QString & );
110 110
111 /** 111 /**
112 Set time zone from a timezone string (e.g. -2:00) 112 Set time zone from a timezone string (e.g. -2:00)
113 */ 113 */
114 void setTimeZone( const QString &tz ); 114 void setTimeZone( const QString &tz );
115 /** 115 /**
116 Set time zone from a minutes value (e.g. -60) 116 Set time zone from a minutes value (e.g. -60)
117 */ 117 */
118 void setTimeZone( int tz ); 118 void setTimeZone( int tz );
119 /** 119 /**
120 Return time zone as offest in minutes. 120 Return time zone as offest in minutes.
121 */ 121 */
122 int getTimeZone() const; 122 int getTimeZone() const;
123 /** 123 /**
124 Compute an ISO 8601 format string from the time zone. 124 Compute an ISO 8601 format string from the time zone.
125 */ 125 */
126 QString getTimeZoneStr() const; 126 QString getTimeZoneStr() const;
127 /** 127 /**
128 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 128 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
129 values). 129 values).
130 */ 130 */
131 void setTimeZoneId( const QString & ); 131 void setTimeZoneId( const QString & );
132 /** 132 /**
133 Return time zone id. 133 Return time zone id.
134 */ 134 */
135 QString timeZoneId() const; 135 QString timeZoneId() const;
136 /** 136 /**
137 Use local time, not UTC or a time zone. 137 Use local time, not UTC or a time zone.
138 */ 138 */
139 void setLocalTime(); 139 void setLocalTime();
140 /** 140 /**
141 Return whether local time is being used. 141 Return whether local time is being used.
142 */ 142 */
143 bool isLocalTime() const; 143 bool isLocalTime() const;
144 144
145 /** 145 /**
146 Add an incidence to calendar. 146 Add an incidence to calendar.
147 147
148 @return true on success, false on error. 148 @return true on success, false on error.
149 */ 149 */
150 virtual bool addIncidence( Incidence * ); 150 virtual bool addIncidence( Incidence * );
151 151
152 // Adds an incidence and all relatedto incidences to the cal 152 // Adds an incidence and all relatedto incidences to the cal
153 void addIncidenceBranch( Incidence * ); 153 void addIncidenceBranch( Incidence * );
154 /** 154 /**
155 Return filtered list of all incidences of this calendar. 155 Return filtered list of all incidences of this calendar.
156 */ 156 */
157 virtual QPtrList<Incidence> incidences(); 157 virtual QPtrList<Incidence> incidences();
158 158
159 /** 159 /**
160 Return unfiltered list of all incidences of this calendar. 160 Return unfiltered list of all incidences of this calendar.
161 */ 161 */
162 virtual QPtrList<Incidence> rawIncidences(); 162 virtual QPtrList<Incidence> rawIncidences();
163 163
164 /** 164 /**
165 Adds a Event to this calendar object. 165 Adds a Event to this calendar object.
166 @param anEvent a pointer to the event to add 166 @param anEvent a pointer to the event to add
167 167
168 @return true on success, false on error. 168 @return true on success, false on error.
169 */ 169 */
170 virtual bool addEventNoDup( Event *event ) = 0; 170 virtual bool addEventNoDup( Event *event ) = 0;
171 virtual bool addAnniversaryNoDup( Event *event ) = 0; 171 virtual bool addAnniversaryNoDup( Event *event ) = 0;
172 virtual bool addEvent( Event *anEvent ) = 0; 172 virtual bool addEvent( Event *anEvent ) = 0;
173 /** 173 /**
174 Delete event from calendar. 174 Delete event from calendar.
175 */ 175 */
176 virtual void deleteEvent( Event * ) = 0; 176 virtual void deleteEvent( Event * ) = 0;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index b02f706..ad8ace3 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -1,211 +1,220 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 registerObserver( 0 ); 68 registerObserver( 0 );
69 if ( mDeleteIncidencesOnClose ) 69 if ( mDeleteIncidencesOnClose )
70 close(); 70 close();
71} 71}
72bool CalendarLocal::mergeCalendarFile( QString name ) 72bool CalendarLocal::mergeCalendarFile( QString name )
73{ 73{
74 CalendarLocal calendar( timeZoneId() ); 74 CalendarLocal calendar( timeZoneId() );
75 calendar.setDefaultCalendar( 1 ); 75 calendar.setDefaultCalendar( 1 );
76 if ( calendar.load( name ) ) { 76 if ( calendar.load( name ) ) {
77 mergeCalendar( &calendar ); 77 mergeCalendar( &calendar );
78 return true; 78 return true;
79 } 79 }
80 return false; 80 return false;
81} 81}
82 82
83Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) 83Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly )
84{ 84{
85 Todo *todo;; 85 Todo *todo;;
86 Incidence *retVal = 0; 86 Incidence *retVal = 0;
87 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 87 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
88 if ( todo->uid() == uid ) { 88 if ( todo->uid() == uid ) {
89 if ( enabledOnly )
90 if ( !todo->calEnabled() )
91 continue;
89 if ( doNotCheckDuplicates ) return todo; 92 if ( doNotCheckDuplicates ) return todo;
90 if ( retVal ) { 93 if ( retVal ) {
91 if ( retVal->calID() > todo->calID() ) { 94 if ( retVal->calID() > todo->calID() ) {
92 retVal = todo; 95 retVal = todo;
93 } 96 }
94 } else { 97 } else {
95 retVal = todo; 98 retVal = todo;
96 } 99 }
97 } 100 }
98 } 101 }
99 if ( retVal ) return retVal; 102 if ( retVal ) return retVal;
100 Event *event; 103 Event *event;
101 for ( event = mEventList.first(); event; event = mEventList.next() ) { 104 for ( event = mEventList.first(); event; event = mEventList.next() ) {
102 if ( event->uid() == uid ) { 105 if ( event->uid() == uid ) {
106 if ( enabledOnly )
107 if ( !event->calEnabled() )
108 continue;
103 if ( doNotCheckDuplicates ) return event; 109 if ( doNotCheckDuplicates ) return event;
104 if ( retVal ) { 110 if ( retVal ) {
105 if ( retVal->calID() > event->calID() ) { 111 if ( retVal->calID() > event->calID() ) {
106 retVal = event; 112 retVal = event;
107 } 113 }
108 } else { 114 } else {
109 retVal = event; 115 retVal = event;
110 } 116 }
111 } 117 }
112 } 118 }
113 if ( retVal ) return retVal; 119 if ( retVal ) return retVal;
114 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 120 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
115 if ( it->uid() == uid ) { 121 if ( it->uid() == uid ) {
122 if ( enabledOnly )
123 if ( !it->calEnabled() )
124 continue;
116 if ( doNotCheckDuplicates ) return it; 125 if ( doNotCheckDuplicates ) return it;
117 if ( retVal ) { 126 if ( retVal ) {
118 if ( retVal->calID() > it->calID() ) { 127 if ( retVal->calID() > it->calID() ) {
119 retVal = it; 128 retVal = it;
120 } 129 }
121 } else { 130 } else {
122 retVal = it; 131 retVal = it;
123 } 132 }
124 } 133 }
125 return retVal; 134 return retVal;
126} 135}
127 136
128bool CalendarLocal::mergeCalendar( Calendar* remote ) 137bool CalendarLocal::mergeCalendar( Calendar* remote )
129{ 138{
130 // 1 look for raw inc in local 139 // 1 look for raw inc in local
131 // if inc not in remote, delete in local 140 // if inc not in remote, delete in local
132 // 2 look for raw inc in remote 141 // 2 look for raw inc in remote
133 // if inc in local, replace it 142 // if inc in local, replace it
134 // if not in local, add it to default calendar 143 // if not in local, add it to default calendar
135 QPtrList<Incidence> localInc = rawIncidences(); 144 QPtrList<Incidence> localInc = rawIncidences();
136 Incidence* inL = localInc.first(); 145 Incidence* inL = localInc.first();
137 while ( inL ) { 146 while ( inL ) {
138 if ( ! inL->isReadOnly () ) 147 if ( ! inL->isReadOnly () )
139 if ( !remote->incidenceForUid( inL->uid(), true )) 148 if ( !remote->incidenceForUid( inL->uid(), true ))
140 deleteIncidence( inL ); 149 deleteIncidence( inL );
141 inL = localInc.next(); 150 inL = localInc.next();
142 } 151 }
143 QPtrList<Incidence> er = remote->rawIncidences(); 152 QPtrList<Incidence> er = remote->rawIncidences();
144 Incidence* inR = er.first(); 153 Incidence* inR = er.first();
145 while ( inR ) { 154 while ( inR ) {
146 inL = incidenceForUid( inR->uid(),false ); 155 inL = incidenceForUid( inR->uid(),false );
147 if ( inL ) { 156 if ( inL ) {
148 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { 157 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) {
149 int calID = inL->calID(); 158 int calID = inL->calID();
150 deleteIncidence( inL ); 159 deleteIncidence( inL );
151 inL = inR->clone(); 160 inL = inR->clone();
152 inL->setCalID_block( calID ); 161 inL->setCalID_block( calID );
153 addIncidence( inL ); 162 addIncidence( inL );
154 } 163 }
155 } else { 164 } else {
156 inL = inR->clone(); 165 inL = inR->clone();
157 inL->setCalID_block( 0 );// add to default cal 166 inL->setCalID_block( 0 );// add to default cal
158 addIncidence( inL ); 167 addIncidence( inL );
159 } 168 }
160 inR = er.next(); 169 inR = er.next();
161 } 170 }
162 return true; 171 return true;
163} 172}
164 173
165 174
166bool CalendarLocal::addCalendarFile( QString name, int id ) 175bool CalendarLocal::addCalendarFile( QString name, int id )
167{ 176{
168 CalendarLocal calendar( timeZoneId() ); 177 CalendarLocal calendar( timeZoneId() );
169 calendar.setDefaultCalendar( id ); 178 calendar.setDefaultCalendar( id );
170 if ( calendar.load( name ) ) { 179 if ( calendar.load( name ) ) {
171 addCalendar( &calendar ); 180 addCalendar( &calendar );
172 return true; 181 return true;
173 } 182 }
174 return false; 183 return false;
175} 184}
176void CalendarLocal::setSyncEventsEnabled() 185void CalendarLocal::setSyncEventsEnabled()
177{ 186{
178 Event * ev; 187 Event * ev;
179 ev = mEventList.first(); 188 ev = mEventList.first();
180 while ( ev ) { 189 while ( ev ) {
181 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 190 if ( ev->uid().left(15) == QString("last-syncEvent-") )
182 ev->setCalEnabled( true ); 191 ev->setCalEnabled( true );
183 ev = mEventList.next(); 192 ev = mEventList.next();
184 } 193 }
185} 194}
186void CalendarLocal::setSyncEventsReadOnly() 195void CalendarLocal::setSyncEventsReadOnly()
187{ 196{
188 Event * ev; 197 Event * ev;
189 ev = mEventList.first(); 198 ev = mEventList.first();
190 while ( ev ) { 199 while ( ev ) {
191 if ( ev->uid().left(15) == QString("last-syncEvent-") ) { 200 if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
192 ev->setReadOnly( true ); 201 ev->setReadOnly( true );
193 } 202 }
194 ev = mEventList.next(); 203 ev = mEventList.next();
195 } 204 }
196} 205}
197 206
198void CalendarLocal::addCalendar( Calendar* cal ) 207void CalendarLocal::addCalendar( Calendar* cal )
199{ 208{
200 cal->setDontDeleteIncidencesOnClose(); 209 cal->setDontDeleteIncidencesOnClose();
201 setSyncEventsEnabled(); 210 setSyncEventsEnabled();
202 { 211 {
203 QPtrList<Event> EventList = cal->rawEvents(); 212 QPtrList<Event> EventList = cal->rawEvents();
204 QPtrList<Event> el; 213 QPtrList<Event> el;
205 Event * ev = EventList.first(); 214 Event * ev = EventList.first();
206 while ( ev ) { 215 while ( ev ) {
207 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { 216 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
208 Event * se = event( ev->uid() ); 217 Event * se = event( ev->uid() );
209 if ( se ) 218 if ( se )
210 el.append( se ); 219 el.append( se );
211 ev->setCalID_block( 1 ); 220 ev->setCalID_block( 1 );
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b70f0c9..b611704 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,146 +1,146 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 bool mergeCalendarFile( QString name ); 48 bool mergeCalendarFile( QString name );
49 bool mergeCalendar( Calendar* cal ); 49 bool mergeCalendar( Calendar* cal );
50 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); 50 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false );
51 void setSyncEventsReadOnly(); 51 void setSyncEventsReadOnly();
52 void setSyncEventsEnabled(); 52 void setSyncEventsEnabled();
53 void stopAllTodos(); 53 void stopAllTodos();
54 /** 54 /**
55 Loads a calendar on disk in vCalendar or iCalendar format into the current 55 Loads a calendar on disk in vCalendar or iCalendar format into the current
56 calendar. Any information already present is lost. 56 calendar. Any information already present is lost.
57 @return true, if successfull, false on error. 57 @return true, if successfull, false on error.
58 @param fileName the name of the calendar on disk. 58 @param fileName the name of the calendar on disk.
59 */ 59 */
60 bool load( const QString &fileName ); 60 bool load( const QString &fileName );
61 /** 61 /**
62 Writes out the calendar to disk in the specified \a format. 62 Writes out the calendar to disk in the specified \a format.
63 CalendarLocal takes ownership of the CalFormat object. 63 CalendarLocal takes ownership of the CalFormat object.
64 @return true, if successfull, false on error. 64 @return true, if successfull, false on error.
65 @param fileName the name of the file 65 @param fileName the name of the file
66 */ 66 */
67 bool save( const QString &fileName, CalFormat *format = 0 ); 67 bool save( const QString &fileName, CalFormat *format = 0 );
68 68
69 /** 69 /**
70 Clears out the current calendar, freeing all used memory etc. etc. 70 Clears out the current calendar, freeing all used memory etc. etc.
71 */ 71 */
72 void close(); 72 void close();
73 73
74 void save() {} 74 void save() {}
75 75
76 /** 76 /**
77 Add Event to calendar. 77 Add Event to calendar.
78 */ 78 */
79 void removeSyncInfo( QString syncProfile); 79 void removeSyncInfo( QString syncProfile);
80 bool addAnniversaryNoDup( Event *event ); 80 bool addAnniversaryNoDup( Event *event );
81 bool addEventNoDup( Event *event ); 81 bool addEventNoDup( Event *event );
82 bool addEvent( Event *event ); 82 bool addEvent( Event *event );
83 /** 83 /**
84 Deletes an event from this calendar. 84 Deletes an event from this calendar.
85 */ 85 */
86 void deleteEvent( Event *event ); 86 void deleteEvent( Event *event );
87 87
88 /** 88 /**
89 Retrieves an event on the basis of the unique string ID. 89 Retrieves an event on the basis of the unique string ID.
90 */ 90 */
91 Event *event( const QString &uid ); 91 Event *event( const QString &uid );
92 /** 92 /**
93 Return unfiltered list of all events in calendar. 93 Return unfiltered list of all events in calendar.
94 */ 94 */
95 QPtrList<Event> rawEvents(); 95 QPtrList<Event> rawEvents();
96 QPtrList<Event> getExternLastSyncEvents(); 96 QPtrList<Event> getExternLastSyncEvents();
97 /** 97 /**
98 Add a todo to the todolist. 98 Add a todo to the todolist.
99 */ 99 */
100 bool addTodo( Todo *todo ); 100 bool addTodo( Todo *todo );
101 bool addTodoNoDup( Todo *todo ); 101 bool addTodoNoDup( Todo *todo );
102 /** 102 /**
103 Remove a todo from the todolist. 103 Remove a todo from the todolist.
104 */ 104 */
105 void deleteTodo( Todo * ); 105 void deleteTodo( Todo * );
106 /** 106 /**
107 Searches todolist for an event with this unique string identifier, 107 Searches todolist for an event with this unique string identifier,
108 returns a pointer or null. 108 returns a pointer or null.
109 */ 109 */
110 Todo *todo( const QString &uid ); 110 Todo *todo( const QString &uid );
111 /** 111 /**
112 Return list of all todos. 112 Return list of all todos.
113 */ 113 */
114 QPtrList<Todo> rawTodos(); 114 QPtrList<Todo> rawTodos();
115 /** 115 /**
116 Returns list of todos due on the specified date. 116 Returns list of todos due on the specified date.
117 */ 117 */
118 QPtrList<Todo> todos( const QDate &date ); 118 QPtrList<Todo> todos( const QDate &date );
119 /** 119 /**
120 Return list of all todos. 120 Return list of all todos.
121 121
122 Workaround because compiler does not recognize function of base class. 122 Workaround because compiler does not recognize function of base class.
123 */ 123 */
124 QPtrList<Todo> todos() { return Calendar::todos(); } 124 QPtrList<Todo> todos() { return Calendar::todos(); }
125 125
126 /** 126 /**
127 Add a Journal entry to calendar. 127 Add a Journal entry to calendar.
128 */ 128 */
129 bool addJournal( Journal * ); 129 bool addJournal( Journal * );
130 /** 130 /**
131 Remove a Journal from the calendar. 131 Remove a Journal from the calendar.
132 */ 132 */
133 void deleteJournal( Journal * ); 133 void deleteJournal( Journal * );
134 /** 134 /**
135 Return Journal for given date. 135 Return Journal for given date.
136 */ 136 */
137 Journal *journal( const QDate & ); 137 Journal *journal( const QDate & );
138 QPtrList<Journal> journals4Date( const QDate & ); 138 QPtrList<Journal> journals4Date( const QDate & );
139 /** 139 /**
140 Return Journal with given UID. 140 Return Journal with given UID.
141 */ 141 */
142 Journal *journal( const QString &uid ); 142 Journal *journal( const QString &uid );
143 /** 143 /**
144 Return list of all Journals stored in calendar. 144 Return list of all Journals stored in calendar.
145 */ 145 */
146 QPtrList<Journal> journals(); 146 QPtrList<Journal> journals();