author | zautrix <zautrix> | 2004-10-05 13:34:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 13:34:33 (UTC) |
commit | 191ced43b27c047b0a39f0acdc8ba1f8a58817df (patch) (unidiff) | |
tree | d164ae32c16259d9a8d5c9fdfa74f975d1f10075 | |
parent | a946c09db6f71f595d8bdcb6b34ba3160c5497dc (diff) | |
download | kdepimpi-191ced43b27c047b0a39f0acdc8ba1f8a58817df.zip kdepimpi-191ced43b27c047b0a39f0acdc8ba1f8a58817df.tar.gz kdepimpi-191ced43b27c047b0a39f0acdc8ba1f8a58817df.tar.bz2 |
fix for filewatch and vcal timezone
-rw-r--r-- | korganizer/calendarview.cpp | 3 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 687943e..b1da144 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1421,245 +1421,246 @@ bool CalendarView::importQtopia( const QString &categories, | |||
1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1424 | 1424 | ||
1425 | updateView(); | 1425 | updateView(); |
1426 | return true; | 1426 | return true; |
1427 | 1427 | ||
1428 | #if 0 | 1428 | #if 0 |
1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1430 | mCurrentSyncDevice = "qtopia-XML"; | 1430 | mCurrentSyncDevice = "qtopia-XML"; |
1431 | if ( KOPrefs::instance()->mAskForPreferences ) | 1431 | if ( KOPrefs::instance()->mAskForPreferences ) |
1432 | edit_sync_options(); | 1432 | edit_sync_options(); |
1433 | qApp->processEvents(); | 1433 | qApp->processEvents(); |
1434 | CalendarLocal* calendar = new CalendarLocal(); | 1434 | CalendarLocal* calendar = new CalendarLocal(); |
1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1436 | bool syncOK = false; | 1436 | bool syncOK = false; |
1437 | QtopiaFormat qtopiaFormat; | 1437 | QtopiaFormat qtopiaFormat; |
1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1439 | bool loadOk = true; | 1439 | bool loadOk = true; |
1440 | if ( !categories.isEmpty() ) | 1440 | if ( !categories.isEmpty() ) |
1441 | loadOk = qtopiaFormat.load( calendar, categories ); | 1441 | loadOk = qtopiaFormat.load( calendar, categories ); |
1442 | if ( loadOk && !datebook.isEmpty() ) | 1442 | if ( loadOk && !datebook.isEmpty() ) |
1443 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1443 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1444 | if ( loadOk && !todolist.isEmpty() ) | 1444 | if ( loadOk && !todolist.isEmpty() ) |
1445 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1445 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1446 | 1446 | ||
1447 | if ( loadOk ) { | 1447 | if ( loadOk ) { |
1448 | getEventViewerDialog()->setSyncMode( true ); | 1448 | getEventViewerDialog()->setSyncMode( true ); |
1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1450 | getEventViewerDialog()->setSyncMode( false ); | 1450 | getEventViewerDialog()->setSyncMode( false ); |
1451 | qApp->processEvents(); | 1451 | qApp->processEvents(); |
1452 | if ( syncOK ) { | 1452 | if ( syncOK ) { |
1453 | if ( KOPrefs::instance()->mWriteBackFile ) | 1453 | if ( KOPrefs::instance()->mWriteBackFile ) |
1454 | { | 1454 | { |
1455 | // write back XML file | 1455 | // write back XML file |
1456 | 1456 | ||
1457 | } | 1457 | } |
1458 | setModified( true ); | 1458 | setModified( true ); |
1459 | } | 1459 | } |
1460 | } else { | 1460 | } else { |
1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1463 | question, i18n("Ok")) ; | 1463 | question, i18n("Ok")) ; |
1464 | } | 1464 | } |
1465 | delete calendar; | 1465 | delete calendar; |
1466 | updateView(); | 1466 | updateView(); |
1467 | return syncOK; | 1467 | return syncOK; |
1468 | 1468 | ||
1469 | 1469 | ||
1470 | #endif | 1470 | #endif |
1471 | 1471 | ||
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void CalendarView::setSyncEventsReadOnly() | 1474 | void CalendarView::setSyncEventsReadOnly() |
1475 | { | 1475 | { |
1476 | Event * ev; | 1476 | Event * ev; |
1477 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1477 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1478 | ev = eL.first(); | 1478 | ev = eL.first(); |
1479 | while ( ev ) { | 1479 | while ( ev ) { |
1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1481 | ev->setReadOnly( true ); | 1481 | ev->setReadOnly( true ); |
1482 | ev = eL.next(); | 1482 | ev = eL.next(); |
1483 | } | 1483 | } |
1484 | } | 1484 | } |
1485 | bool CalendarView::openCalendar(QString filename, bool merge) | 1485 | bool CalendarView::openCalendar(QString filename, bool merge) |
1486 | { | 1486 | { |
1487 | 1487 | ||
1488 | if (filename.isEmpty()) { | 1488 | if (filename.isEmpty()) { |
1489 | return false; | 1489 | return false; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | if (!QFile::exists(filename)) { | 1492 | if (!QFile::exists(filename)) { |
1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1494 | return false; | 1494 | return false; |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | globalFlagBlockAgenda = 1; | 1497 | globalFlagBlockAgenda = 1; |
1498 | if (!merge) mCalendar->close(); | 1498 | if (!merge) mCalendar->close(); |
1499 | 1499 | ||
1500 | mStorage->setFileName( filename ); | 1500 | mStorage->setFileName( filename ); |
1501 | 1501 | ||
1502 | if ( mStorage->load() ) { | 1502 | if ( mStorage->load() ) { |
1503 | if ( merge ) ;//setModified( true ); | 1503 | if ( merge ) ;//setModified( true ); |
1504 | else { | 1504 | else { |
1505 | //setModified( true ); | 1505 | //setModified( true ); |
1506 | mViewManager->setDocumentId( filename ); | 1506 | mViewManager->setDocumentId( filename ); |
1507 | mDialogManager->setDocumentId( filename ); | 1507 | mDialogManager->setDocumentId( filename ); |
1508 | mTodoList->setDocumentId( filename ); | 1508 | mTodoList->setDocumentId( filename ); |
1509 | } | 1509 | } |
1510 | globalFlagBlockAgenda = 2; | 1510 | globalFlagBlockAgenda = 2; |
1511 | // if ( getLastSyncEvent() ) | 1511 | // if ( getLastSyncEvent() ) |
1512 | // getLastSyncEvent()->setReadOnly( true ); | 1512 | // getLastSyncEvent()->setReadOnly( true ); |
1513 | mCalendar->reInitAlarmSettings(); | 1513 | mCalendar->reInitAlarmSettings(); |
1514 | setSyncEventsReadOnly(); | 1514 | setSyncEventsReadOnly(); |
1515 | updateUnmanagedViews(); | 1515 | updateUnmanagedViews(); |
1516 | updateView(); | 1516 | updateView(); |
1517 | loadedFileVersion = QDateTime::currentDateTime(); | 1517 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); |
1518 | if ( filename != MainWindow::defaultFileName() ) { | 1518 | if ( filename != MainWindow::defaultFileName() ) { |
1519 | saveCalendar( MainWindow::defaultFileName() ); | 1519 | saveCalendar( MainWindow::defaultFileName() ); |
1520 | watchSavedFile(); | 1520 | watchSavedFile(); |
1521 | } | 1521 | } |
1522 | return true; | 1522 | return true; |
1523 | } else { | 1523 | } else { |
1524 | // while failing to load, the calendar object could | 1524 | // while failing to load, the calendar object could |
1525 | // have become partially populated. Clear it out. | 1525 | // have become partially populated. Clear it out. |
1526 | if ( !merge ) { | 1526 | if ( !merge ) { |
1527 | mCalendar->close(); | 1527 | mCalendar->close(); |
1528 | mViewManager->setDocumentId( filename ); | 1528 | mViewManager->setDocumentId( filename ); |
1529 | mDialogManager->setDocumentId( filename ); | 1529 | mDialogManager->setDocumentId( filename ); |
1530 | mTodoList->setDocumentId( filename ); | 1530 | mTodoList->setDocumentId( filename ); |
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1533 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1534 | 1534 | ||
1535 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1535 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1536 | globalFlagBlockAgenda = 2; | 1536 | globalFlagBlockAgenda = 2; |
1537 | mCalendar->reInitAlarmSettings(); | 1537 | mCalendar->reInitAlarmSettings(); |
1538 | setSyncEventsReadOnly(); | 1538 | setSyncEventsReadOnly(); |
1539 | updateUnmanagedViews(); | 1539 | updateUnmanagedViews(); |
1540 | updateView(); | 1540 | updateView(); |
1541 | } | 1541 | } |
1542 | return false; | 1542 | return false; |
1543 | } | 1543 | } |
1544 | void CalendarView::showOpenError() | 1544 | void CalendarView::showOpenError() |
1545 | { | 1545 | { |
1546 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1546 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1547 | } | 1547 | } |
1548 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1548 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1549 | { | 1549 | { |
1550 | loadedFileVersion = dt; | 1550 | loadedFileVersion = dt; |
1551 | } | 1551 | } |
1552 | bool CalendarView::checkFileChanged(QString fn) | 1552 | bool CalendarView::checkFileChanged(QString fn) |
1553 | { | 1553 | { |
1554 | QFileInfo finf ( fn ); | 1554 | QFileInfo finf ( fn ); |
1555 | if ( !finf.exists() ) | 1555 | if ( !finf.exists() ) |
1556 | return true; | 1556 | return true; |
1557 | QDateTime dt = finf.lastModified (); | 1557 | QDateTime dt = finf.lastModified (); |
1558 | if ( dt <= loadedFileVersion ) | 1558 | if ( dt <= loadedFileVersion ) |
1559 | return false; | 1559 | return false; |
1560 | return true; | 1560 | return true; |
1561 | 1561 | ||
1562 | } | 1562 | } |
1563 | void CalendarView::watchSavedFile() | 1563 | void CalendarView::watchSavedFile() |
1564 | { | 1564 | { |
1565 | QFileInfo finf ( MainWindow::defaultFileName()); | 1565 | QFileInfo finf ( MainWindow::defaultFileName()); |
1566 | if ( !finf.exists() ) | 1566 | if ( !finf.exists() ) |
1567 | return; | 1567 | return; |
1568 | QDateTime dt = finf.lastModified (); | 1568 | QDateTime dt = finf.lastModified (); |
1569 | if ( dt < loadedFileVersion ) { | 1569 | if ( dt < loadedFileVersion ) { |
1570 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | ||
1570 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1571 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1571 | return; | 1572 | return; |
1572 | } | 1573 | } |
1573 | loadedFileVersion = dt; | 1574 | loadedFileVersion = dt; |
1574 | } | 1575 | } |
1575 | 1576 | ||
1576 | bool CalendarView::checkFileVersion(QString fn) | 1577 | bool CalendarView::checkFileVersion(QString fn) |
1577 | { | 1578 | { |
1578 | QFileInfo finf ( fn ); | 1579 | QFileInfo finf ( fn ); |
1579 | if ( !finf.exists() ) | 1580 | if ( !finf.exists() ) |
1580 | return true; | 1581 | return true; |
1581 | QDateTime dt = finf.lastModified (); | 1582 | QDateTime dt = finf.lastModified (); |
1582 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1583 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1583 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1584 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1584 | if ( dt <= loadedFileVersion ) | 1585 | if ( dt <= loadedFileVersion ) |
1585 | return true; | 1586 | return true; |
1586 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1587 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1587 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1588 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1588 | i18n("Sync+save")); | 1589 | i18n("Sync+save")); |
1589 | 1590 | ||
1590 | if ( km == KMessageBox::Cancel ) | 1591 | if ( km == KMessageBox::Cancel ) |
1591 | return false; | 1592 | return false; |
1592 | if ( km == KMessageBox::Yes ) | 1593 | if ( km == KMessageBox::Yes ) |
1593 | return true; | 1594 | return true; |
1594 | 1595 | ||
1595 | setSyncDevice("deleteaftersync" ); | 1596 | setSyncDevice("deleteaftersync" ); |
1596 | KOPrefs::instance()->mAskForPreferences = true; | 1597 | KOPrefs::instance()->mAskForPreferences = true; |
1597 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1598 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1598 | KOPrefs::instance()->mWriteBackFile = false; | 1599 | KOPrefs::instance()->mWriteBackFile = false; |
1599 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1600 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1600 | KOPrefs::instance()->mShowSyncSummary = false; | 1601 | KOPrefs::instance()->mShowSyncSummary = false; |
1601 | syncCalendar( fn, 3 ); | 1602 | syncCalendar( fn, 3 ); |
1602 | Event * e = getLastSyncEvent(); | 1603 | Event * e = getLastSyncEvent(); |
1603 | mCalendar->deleteEvent ( e ); | 1604 | mCalendar->deleteEvent ( e ); |
1604 | updateView(); | 1605 | updateView(); |
1605 | return true; | 1606 | return true; |
1606 | } | 1607 | } |
1607 | 1608 | ||
1608 | bool CalendarView::saveCalendar( QString filename ) | 1609 | bool CalendarView::saveCalendar( QString filename ) |
1609 | { | 1610 | { |
1610 | 1611 | ||
1611 | // Store back all unsaved data into calendar object | 1612 | // Store back all unsaved data into calendar object |
1612 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1613 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1613 | if ( mViewManager->currentView() ) | 1614 | if ( mViewManager->currentView() ) |
1614 | mViewManager->currentView()->flushView(); | 1615 | mViewManager->currentView()->flushView(); |
1615 | 1616 | ||
1616 | //mStorage->setFileName( filename ); | 1617 | //mStorage->setFileName( filename ); |
1617 | 1618 | ||
1618 | mStorage->setSaveFormat( new ICalFormat() ); | 1619 | mStorage->setSaveFormat( new ICalFormat() ); |
1619 | mStorage->setFileName( filename ); | 1620 | mStorage->setFileName( filename ); |
1620 | bool success; | 1621 | bool success; |
1621 | success = mStorage->save(); | 1622 | success = mStorage->save(); |
1622 | if ( !success ) { | 1623 | if ( !success ) { |
1623 | return false; | 1624 | return false; |
1624 | } | 1625 | } |
1625 | 1626 | ||
1626 | return true; | 1627 | return true; |
1627 | } | 1628 | } |
1628 | 1629 | ||
1629 | void CalendarView::closeCalendar() | 1630 | void CalendarView::closeCalendar() |
1630 | { | 1631 | { |
1631 | 1632 | ||
1632 | // child windows no longer valid | 1633 | // child windows no longer valid |
1633 | emit closingDown(); | 1634 | emit closingDown(); |
1634 | 1635 | ||
1635 | mCalendar->close(); | 1636 | mCalendar->close(); |
1636 | setModified(false); | 1637 | setModified(false); |
1637 | updateView(); | 1638 | updateView(); |
1638 | } | 1639 | } |
1639 | 1640 | ||
1640 | void CalendarView::archiveCalendar() | 1641 | void CalendarView::archiveCalendar() |
1641 | { | 1642 | { |
1642 | mDialogManager->showArchiveDialog(); | 1643 | mDialogManager->showArchiveDialog(); |
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | 1646 | ||
1646 | void CalendarView::readSettings() | 1647 | void CalendarView::readSettings() |
1647 | { | 1648 | { |
1648 | 1649 | ||
1649 | 1650 | ||
1650 | // mViewManager->showAgendaView(); | 1651 | // mViewManager->showAgendaView(); |
1651 | QString str; | 1652 | QString str; |
1652 | //qDebug("CalendarView::readSettings() "); | 1653 | //qDebug("CalendarView::readSettings() "); |
1653 | // read settings from the KConfig, supplying reasonable | 1654 | // read settings from the KConfig, supplying reasonable |
1654 | // defaults where none are to be found | 1655 | // defaults where none are to be found |
1655 | KConfig *config = KOGlobals::config(); | 1656 | KConfig *config = KOGlobals::config(); |
1656 | #ifndef KORG_NOSPLITTER | 1657 | #ifndef KORG_NOSPLITTER |
1657 | config->setGroup("KOrganizer Geometry"); | 1658 | config->setGroup("KOrganizer Geometry"); |
1658 | 1659 | ||
1659 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1660 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1660 | if (sizes.count() != 2) { | 1661 | if (sizes.count() != 2) { |
1661 | sizes << mDateNavigator->minimumSizeHint().width(); | 1662 | sizes << mDateNavigator->minimumSizeHint().width(); |
1662 | sizes << 300; | 1663 | sizes << 300; |
1663 | } | 1664 | } |
1664 | mPanner->setSizes(sizes); | 1665 | mPanner->setSizes(sizes); |
1665 | 1666 | ||
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 4727a7a..309c699 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -1391,193 +1391,193 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
1391 | } | 1391 | } |
1392 | 1392 | ||
1393 | // priority | 1393 | // priority |
1394 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1394 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1395 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1395 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1396 | deleteStr(s); | 1396 | deleteStr(s); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | // transparency | 1399 | // transparency |
1400 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1400 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1401 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1401 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1402 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1402 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1403 | deleteStr(s); | 1403 | deleteStr(s); |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | // related event | 1406 | // related event |
1407 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1407 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1408 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1408 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1409 | deleteStr(s); | 1409 | deleteStr(s); |
1410 | mEventsRelate.append(anEvent); | 1410 | mEventsRelate.append(anEvent); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | /* PILOT SYNC STUFF */ | 1413 | /* PILOT SYNC STUFF */ |
1414 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1414 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1415 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1415 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1416 | deleteStr(s); | 1416 | deleteStr(s); |
1417 | } | 1417 | } |
1418 | else | 1418 | else |
1419 | anEvent->setPilotId(0); | 1419 | anEvent->setPilotId(0); |
1420 | 1420 | ||
1421 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1421 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1422 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1422 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1423 | deleteStr(s); | 1423 | deleteStr(s); |
1424 | } | 1424 | } |
1425 | else | 1425 | else |
1426 | anEvent->setSyncStatus(Event::SYNCMOD); | 1426 | anEvent->setSyncStatus(Event::SYNCMOD); |
1427 | 1427 | ||
1428 | return anEvent; | 1428 | return anEvent; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | 1431 | ||
1432 | QString VCalFormat::qDateToISO(const QDate &qd) | 1432 | QString VCalFormat::qDateToISO(const QDate &qd) |
1433 | { | 1433 | { |
1434 | QString tmpStr; | 1434 | QString tmpStr; |
1435 | 1435 | ||
1436 | ASSERT(qd.isValid()); | 1436 | ASSERT(qd.isValid()); |
1437 | 1437 | ||
1438 | tmpStr.sprintf("%.2d%.2d%.2d", | 1438 | tmpStr.sprintf("%.2d%.2d%.2d", |
1439 | qd.year(), qd.month(), qd.day()); | 1439 | qd.year(), qd.month(), qd.day()); |
1440 | return tmpStr; | 1440 | return tmpStr; |
1441 | 1441 | ||
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1444 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1445 | { | 1445 | { |
1446 | QString tmpStr; | 1446 | QString tmpStr; |
1447 | 1447 | ||
1448 | ASSERT(qdt.date().isValid()); | 1448 | ASSERT(qdt.date().isValid()); |
1449 | ASSERT(qdt.time().isValid()); | 1449 | ASSERT(qdt.time().isValid()); |
1450 | if (zulu && !useLocalTime ) { | 1450 | if (zulu && !useLocalTime ) { |
1451 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); | 1451 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1452 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1452 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1453 | tmpDT.date().year(), tmpDT.date().month(), | 1453 | tmpDT.date().year(), tmpDT.date().month(), |
1454 | tmpDT.date().day(), tmpDT.time().hour(), | 1454 | tmpDT.date().day(), tmpDT.time().hour(), |
1455 | tmpDT.time().minute(), tmpDT.time().second()); | 1455 | tmpDT.time().minute(), tmpDT.time().second()); |
1456 | } else { | 1456 | } else { |
1457 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1457 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1458 | qdt.date().year(), qdt.date().month(), | 1458 | qdt.date().year(), qdt.date().month(), |
1459 | qdt.date().day(), qdt.time().hour(), | 1459 | qdt.date().day(), qdt.time().hour(), |
1460 | qdt.time().minute(), qdt.time().second()); | 1460 | qdt.time().minute(), qdt.time().second()); |
1461 | } | 1461 | } |
1462 | return tmpStr; | 1462 | return tmpStr; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1465 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) |
1466 | { | 1466 | { |
1467 | QDate tmpDate; | 1467 | QDate tmpDate; |
1468 | QTime tmpTime; | 1468 | QTime tmpTime; |
1469 | QString tmpStr; | 1469 | QString tmpStr; |
1470 | int year, month, day, hour, minute, second; | 1470 | int year, month, day, hour, minute, second; |
1471 | 1471 | ||
1472 | tmpStr = dtStr; | 1472 | tmpStr = dtStr; |
1473 | year = tmpStr.left(4).toInt(); | 1473 | year = tmpStr.left(4).toInt(); |
1474 | month = tmpStr.mid(4,2).toInt(); | 1474 | month = tmpStr.mid(4,2).toInt(); |
1475 | day = tmpStr.mid(6,2).toInt(); | 1475 | day = tmpStr.mid(6,2).toInt(); |
1476 | hour = tmpStr.mid(9,2).toInt(); | 1476 | hour = tmpStr.mid(9,2).toInt(); |
1477 | minute = tmpStr.mid(11,2).toInt(); | 1477 | minute = tmpStr.mid(11,2).toInt(); |
1478 | second = tmpStr.mid(13,2).toInt(); | 1478 | second = tmpStr.mid(13,2).toInt(); |
1479 | tmpDate.setYMD(year, month, day); | 1479 | tmpDate.setYMD(year, month, day); |
1480 | tmpTime.setHMS(hour, minute, second); | 1480 | tmpTime.setHMS(hour, minute, second); |
1481 | 1481 | ||
1482 | ASSERT(tmpDate.isValid()); | 1482 | ASSERT(tmpDate.isValid()); |
1483 | ASSERT(tmpTime.isValid()); | 1483 | ASSERT(tmpTime.isValid()); |
1484 | QDateTime tmpDT(tmpDate, tmpTime); | 1484 | QDateTime tmpDT(tmpDate, tmpTime); |
1485 | // correct for GMT if string is in Zulu format | 1485 | // correct for GMT if string is in Zulu format |
1486 | if (dtStr.at(dtStr.length()-1) == 'Z') | 1486 | if (dtStr.at(dtStr.length()-1) == 'Z') |
1487 | tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone()); | 1487 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); |
1488 | return tmpDT; | 1488 | return tmpDT; |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1491 | QDate VCalFormat::ISOToQDate(const QString &dateStr) |
1492 | { | 1492 | { |
1493 | int year, month, day; | 1493 | int year, month, day; |
1494 | 1494 | ||
1495 | year = dateStr.left(4).toInt(); | 1495 | year = dateStr.left(4).toInt(); |
1496 | month = dateStr.mid(4,2).toInt(); | 1496 | month = dateStr.mid(4,2).toInt(); |
1497 | day = dateStr.mid(6,2).toInt(); | 1497 | day = dateStr.mid(6,2).toInt(); |
1498 | 1498 | ||
1499 | return(QDate(year, month, day)); | 1499 | return(QDate(year, month, day)); |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1502 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1503 | // and break it down from it's tree-like format into the dictionary format | 1503 | // and break it down from it's tree-like format into the dictionary format |
1504 | // that is used internally in the VCalFormat. | 1504 | // that is used internally in the VCalFormat. |
1505 | void VCalFormat::populate(VObject *vcal) | 1505 | void VCalFormat::populate(VObject *vcal) |
1506 | { | 1506 | { |
1507 | // this function will populate the caldict dictionary and other event | 1507 | // this function will populate the caldict dictionary and other event |
1508 | // lists. It turns vevents into Events and then inserts them. | 1508 | // lists. It turns vevents into Events and then inserts them. |
1509 | 1509 | ||
1510 | VObjectIterator i; | 1510 | VObjectIterator i; |
1511 | VObject *curVO, *curVOProp; | 1511 | VObject *curVO, *curVOProp; |
1512 | Event *anEvent; | 1512 | Event *anEvent; |
1513 | 1513 | ||
1514 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1514 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1515 | char *methodType = 0; | 1515 | char *methodType = 0; |
1516 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1516 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1517 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1517 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1518 | << methodType << "'" << endl; | 1518 | << methodType << "'" << endl; |
1519 | delete methodType; | 1519 | delete methodType; |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | // warn the user that we might have trouble reading non-known calendar. | 1522 | // warn the user that we might have trouble reading non-known calendar. |
1523 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1523 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1524 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1524 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1525 | if (strcmp(productId().local8Bit(), s) != 0) | 1525 | if (strcmp(productId().local8Bit(), s) != 0) |
1526 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1526 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1527 | "or any other product we support. Loading anyway..." << endl; | 1527 | "or any other product we support. Loading anyway..." << endl; |
1528 | mLoadedProductId = s; | 1528 | mLoadedProductId = s; |
1529 | deleteStr(s); | 1529 | deleteStr(s); |
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | // warn the user we might have trouble reading this unknown version. | 1532 | // warn the user we might have trouble reading this unknown version. |
1533 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1533 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1534 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1534 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1535 | if (strcmp(_VCAL_VERSION, s) != 0) | 1535 | if (strcmp(_VCAL_VERSION, s) != 0) |
1536 | kdDebug() << "This vCalendar file has version " << s | 1536 | kdDebug() << "This vCalendar file has version " << s |
1537 | << "We only support " << _VCAL_VERSION << endl; | 1537 | << "We only support " << _VCAL_VERSION << endl; |
1538 | deleteStr(s); | 1538 | deleteStr(s); |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | // set the time zone | 1541 | // set the time zone |
1542 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1542 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1543 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1543 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1544 | mCalendar->setTimeZone(s); | 1544 | mCalendar->setTimeZone(s); |
1545 | deleteStr(s); | 1545 | deleteStr(s); |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | 1548 | ||
1549 | // Store all events with a relatedTo property in a list for post-processing | 1549 | // Store all events with a relatedTo property in a list for post-processing |
1550 | mEventsRelate.clear(); | 1550 | mEventsRelate.clear(); |
1551 | mTodosRelate.clear(); | 1551 | mTodosRelate.clear(); |
1552 | 1552 | ||
1553 | initPropIterator(&i, vcal); | 1553 | initPropIterator(&i, vcal); |
1554 | 1554 | ||
1555 | // go through all the vobjects in the vcal | 1555 | // go through all the vobjects in the vcal |
1556 | while (moreIteration(&i)) { | 1556 | while (moreIteration(&i)) { |
1557 | curVO = nextVObject(&i); | 1557 | curVO = nextVObject(&i); |
1558 | 1558 | ||
1559 | /************************************************************************/ | 1559 | /************************************************************************/ |
1560 | 1560 | ||
1561 | // now, check to see that the object is an event or todo. | 1561 | // now, check to see that the object is an event or todo. |
1562 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1562 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1563 | 1563 | ||
1564 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1564 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1565 | char *s; | 1565 | char *s; |
1566 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1566 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1567 | // check to see if event was deleted by the kpilot conduit | 1567 | // check to see if event was deleted by the kpilot conduit |
1568 | if (atoi(s) == Event::SYNCDEL) { | 1568 | if (atoi(s) == Event::SYNCDEL) { |
1569 | deleteStr(s); | 1569 | deleteStr(s); |
1570 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1570 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1571 | goto SKIP; | 1571 | goto SKIP; |
1572 | } | 1572 | } |
1573 | deleteStr(s); | 1573 | deleteStr(s); |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | // this code checks to see if we are trying to read in an event | 1576 | // this code checks to see if we are trying to read in an event |
1577 | // that we already find to be in the calendar. If we find this | 1577 | // that we already find to be in the calendar. If we find this |
1578 | // to be the case, we skip the event. | 1578 | // to be the case, we skip the event. |
1579 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1579 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1580 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1580 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1581 | QString tmpStr(s); | 1581 | QString tmpStr(s); |
1582 | deleteStr(s); | 1582 | deleteStr(s); |
1583 | 1583 | ||