author | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
commit | e08811c2246f63b2b63f9db6b65701344460f3d7 (patch) (unidiff) | |
tree | d450f486a9472d80eb86f605237b828a0e7ffae6 /korganizer/calendarview.cpp | |
parent | 854d4a0c686962cd73ac7418b5fbf4b2d73adab7 (diff) | |
download | kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.zip kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.gz kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.bz2 |
ync
-rw-r--r-- | korganizer/calendarview.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d024c1..1800cf2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1583,48 +1583,49 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t | |||
1583 | 1583 | ||
1584 | while ( eve ) { | 1584 | while ( eve ) { |
1585 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1585 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1586 | if ( !id.isEmpty() ) { | 1586 | if ( !id.isEmpty() ) { |
1587 | QString des = eve->description(); | 1587 | QString des = eve->description(); |
1588 | QString pref = "e"; | 1588 | QString pref = "e"; |
1589 | if ( toDelete->typeID() == todoID ) | 1589 | if ( toDelete->typeID() == todoID ) |
1590 | pref = "t"; | 1590 | pref = "t"; |
1591 | des += pref+ id + ","; | 1591 | des += pref+ id + ","; |
1592 | eve->setReadOnly( false ); | 1592 | eve->setReadOnly( false ); |
1593 | eve->setDescription( des ); | 1593 | eve->setDescription( des ); |
1594 | //qDebug("setdes %s ", des.latin1()); | 1594 | //qDebug("setdes %s ", des.latin1()); |
1595 | eve->setReadOnly( true ); | 1595 | eve->setReadOnly( true ); |
1596 | } | 1596 | } |
1597 | eve = lastSync.next(); | 1597 | eve = lastSync.next(); |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | } | 1600 | } |
1601 | void CalendarView::checkExternalId( Incidence * inc ) | 1601 | void CalendarView::checkExternalId( Incidence * inc ) |
1602 | { | 1602 | { |
1603 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1603 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1604 | checkExternSyncEvent( lastSync, inc ); | 1604 | checkExternSyncEvent( lastSync, inc ); |
1605 | 1605 | ||
1606 | } | 1606 | } |
1607 | // SSSSSSSSSSSSSSSSSSSSSS | ||
1607 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1608 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1608 | { | 1609 | { |
1609 | 1610 | ||
1610 | bool syncOK = true; | 1611 | bool syncOK = true; |
1611 | int addedEvent = 0; | 1612 | int addedEvent = 0; |
1612 | int addedEventR = 0; | 1613 | int addedEventR = 0; |
1613 | int deletedEventR = 0; | 1614 | int deletedEventR = 0; |
1614 | int deletedEventL = 0; | 1615 | int deletedEventL = 0; |
1615 | int changedLocal = 0; | 1616 | int changedLocal = 0; |
1616 | int changedRemote = 0; | 1617 | int changedRemote = 0; |
1617 | int filteredIN = 0; | 1618 | int filteredIN = 0; |
1618 | int filteredOUT = 0; | 1619 | int filteredOUT = 0; |
1619 | //QPtrList<Event> el = local->rawEvents(); | 1620 | //QPtrList<Event> el = local->rawEvents(); |
1620 | Event* eventR; | 1621 | Event* eventR; |
1621 | QString uid; | 1622 | QString uid; |
1622 | int take; | 1623 | int take; |
1623 | Event* eventRSync; | 1624 | Event* eventRSync; |
1624 | Event* eventLSync; | 1625 | Event* eventLSync; |
1625 | clearAllViews(); | 1626 | clearAllViews(); |
1626 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1627 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1627 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1628 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1628 | bool fullDateRange = false; | 1629 | bool fullDateRange = false; |
1629 | local->resetTempSyncStat(); | 1630 | local->resetTempSyncStat(); |
1630 | mLastCalendarSync = QDateTime::currentDateTime(); | 1631 | mLastCalendarSync = QDateTime::currentDateTime(); |
@@ -1702,89 +1703,103 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1702 | } | 1703 | } |
1703 | int w = 300; | 1704 | int w = 300; |
1704 | if ( QApplication::desktop()->width() < 320 ) | 1705 | if ( QApplication::desktop()->width() < 320 ) |
1705 | w = 220; | 1706 | w = 220; |
1706 | int h = bar.sizeHint().height() ; | 1707 | int h = bar.sizeHint().height() ; |
1707 | int dw = QApplication::desktop()->width(); | 1708 | int dw = QApplication::desktop()->width(); |
1708 | int dh = QApplication::desktop()->height(); | 1709 | int dh = QApplication::desktop()->height(); |
1709 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1710 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1710 | bar.show(); | 1711 | bar.show(); |
1711 | int modulo = (er.count()/10)+1; | 1712 | int modulo = (er.count()/10)+1; |
1712 | int incCounter = 0; | 1713 | int incCounter = 0; |
1713 | while ( inR ) { | 1714 | while ( inR ) { |
1714 | if ( ! bar.isVisible() ) | 1715 | if ( ! bar.isVisible() ) |
1715 | return false; | 1716 | return false; |
1716 | if ( incCounter % modulo == 0 ) | 1717 | if ( incCounter % modulo == 0 ) |
1717 | bar.setProgress( incCounter ); | 1718 | bar.setProgress( incCounter ); |
1718 | ++incCounter; | 1719 | ++incCounter; |
1719 | uid = inR->uid(); | 1720 | uid = inR->uid(); |
1720 | bool skipIncidence = false; | 1721 | bool skipIncidence = false; |
1721 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1722 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1722 | skipIncidence = true; | 1723 | skipIncidence = true; |
1723 | QString idS; | 1724 | QString idS; |
1724 | qApp->processEvents(); | 1725 | qApp->processEvents(); |
1725 | if ( !skipIncidence ) { | 1726 | if ( !skipIncidence ) { |
1726 | inL = local->incidenceForUid( uid , false , true ); | 1727 | int hasCalId = 0; |
1728 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | ||
1729 | if ( hasCalId && !inL ) | ||
1730 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | ||
1731 | else | ||
1732 | hasCalId = 0; | ||
1727 | if ( inL ) { // maybe conflict - same uid in both calendars | 1733 | if ( inL ) { // maybe conflict - same uid in both calendars |
1734 | if ( hasCalId ) | ||
1735 | qDebug("KO: Cal id %d conflict detected: %s ", hasCalId, inL->summary().latin1()); | ||
1728 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1736 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1729 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1737 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1730 | if ( take == 3 ) | 1738 | if ( take == 3 ) |
1731 | return false; | 1739 | return false; |
1732 | if ( take == 1 ) {// take local ********************** | 1740 | if ( take == 1 ) {// take local ********************** |
1733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1734 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1742 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1735 | else | 1743 | else |
1736 | idS = inR->IDStr(); | 1744 | idS = inR->IDStr(); |
1737 | int calID = inR->calID(); | 1745 | int calID = inR->calID(); |
1738 | remote->deleteIncidence( inR ); | 1746 | remote->deleteIncidence( inR ); |
1739 | inR = inL->clone(); | 1747 | inR = inL->clone(); |
1740 | inR->setCalID_block( calID ); | 1748 | inR->setCalID_block( calID ); |
1741 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1749 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1742 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1750 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1743 | inR->setIDStr( idS ); | 1751 | inR->setIDStr( idS ); |
1744 | remote->addIncidence( inR ); | 1752 | remote->addIncidence( inR ); |
1745 | if ( mSyncManager->syncWithDesktop() ) | 1753 | if ( mSyncManager->syncWithDesktop() ) |
1746 | inR->setPilotId( 2 ); | 1754 | inR->setPilotId( 2 ); |
1747 | ++changedRemote; | 1755 | ++changedRemote; |
1748 | } else {// take remote ********************** | 1756 | } else {// take remote ********************** |
1749 | if ( !inL->isReadOnly() ) { | 1757 | if ( !inL->isReadOnly() ) { |
1750 | idS = inL->IDStr(); | 1758 | idS = inL->IDStr(); |
1751 | int pid = inL->pilotId(); | 1759 | int pid = inL->pilotId(); |
1752 | int calID = inL->calID(); | 1760 | int calID = inL->calID(); |
1761 | if ( hasCalId ) | ||
1762 | calID = hasCalId; | ||
1753 | local->deleteIncidence( inL ); | 1763 | local->deleteIncidence( inL ); |
1754 | inL = inR->clone(); | 1764 | inL = inR->clone(); |
1755 | inL->setCalID_block( calID ); | 1765 | inL->setCalID_block( calID ); |
1756 | if ( mSyncManager->syncWithDesktop() ) | 1766 | if ( mSyncManager->syncWithDesktop() ) |
1757 | inL->setPilotId( pid ); | 1767 | inL->setPilotId( pid ); |
1758 | inL->setIDStr( idS ); | 1768 | inL->setIDStr( idS ); |
1759 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1769 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1760 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1770 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1761 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1771 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1762 | } | 1772 | } |
1763 | local->addIncidence( inL ); | 1773 | local->addIncidence( inL ); |
1764 | ++changedLocal; | 1774 | ++changedLocal; |
1765 | } | 1775 | } |
1766 | } | 1776 | } |
1777 | } else { | ||
1778 | // take == 0; events equal | ||
1779 | if ( hasCalId ) | ||
1780 | qDebug("EV EQUALLLL **************************** "); | ||
1781 | |||
1767 | } | 1782 | } |
1768 | } else { // no conflict ********** add or delete remote | 1783 | } else { // no conflict ********** add or delete remote |
1769 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1784 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1770 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1771 | QString des = eventLSync->description(); | 1786 | QString des = eventLSync->description(); |
1772 | QString pref = "e"; | 1787 | QString pref = "e"; |
1773 | if ( inR->typeID() == todoID ) | 1788 | if ( inR->typeID() == todoID ) |
1774 | pref = "t"; | 1789 | pref = "t"; |
1775 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1790 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1776 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1791 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1777 | //remote->deleteIncidence( inR ); | 1792 | //remote->deleteIncidence( inR ); |
1778 | ++deletedEventR; | 1793 | ++deletedEventR; |
1779 | } else { | 1794 | } else { |
1780 | inR->setLastModified( modifiedCalendar ); | 1795 | inR->setLastModified( modifiedCalendar ); |
1781 | inL = inR->clone(); | 1796 | inL = inR->clone(); |
1782 | inL->setIDStr( ":" ); | 1797 | inL->setIDStr( ":" ); |
1783 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1798 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1784 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1799 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1785 | 1800 | ||
1786 | inL->setCalID_block( 0 );// add to default cal | 1801 | inL->setCalID_block( 0 );// add to default cal |
1787 | local->addIncidence( inL ); | 1802 | local->addIncidence( inL ); |
1788 | ++addedEvent; | 1803 | ++addedEvent; |
1789 | 1804 | ||
1790 | } | 1805 | } |