summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 07:28:54 (UTC)
committer zautrix <zautrix>2004-10-07 07:28:54 (UTC)
commit77280f6a176a15b60004f312e6cacdfbbd3909c1 (patch) (unidiff)
treee074d4abedc2f4cc575e5655575e038b9d460106
parentf1eb5b74c962909851607c4b4cb05ee18a347d37 (diff)
downloadkdepimpi-77280f6a176a15b60004f312e6cacdfbbd3909c1.zip
kdepimpi-77280f6a176a15b60004f312e6cacdfbbd3909c1.tar.gz
kdepimpi-77280f6a176a15b60004f312e6cacdfbbd3909c1.tar.bz2
sync changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp31
-rw-r--r--kaddressbook/kabcore.h7
-rw-r--r--korganizer/koprefs.cpp2
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp321
-rw-r--r--korganizer/mainwindow.h70
-rw-r--r--libkdepim/kpimprefs.cpp3
-rw-r--r--libkdepim/kpimprefs.h3
-rw-r--r--libkdepim/ksyncmanager.cpp567
-rw-r--r--libkdepim/ksyncmanager.h107
10 files changed, 646 insertions, 468 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d9eb391..83fede4 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1494,384 +1494,388 @@ void KABCore::addGUIClient( KXMLGUIClient *client )
1494 1494
1495 1495
1496void KABCore::configurationChanged() 1496void KABCore::configurationChanged()
1497{ 1497{
1498 mExtensionManager->reconfigure(); 1498 mExtensionManager->reconfigure();
1499} 1499}
1500 1500
1501void KABCore::addressBookChanged() 1501void KABCore::addressBookChanged()
1502{ 1502{
1503/*US 1503/*US
1504 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1504 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1505 while ( it.current() ) { 1505 while ( it.current() ) {
1506 if ( it.current()->dirty() ) { 1506 if ( it.current()->dirty() ) {
1507 QString text = i18n( "Data has been changed externally. Unsaved " 1507 QString text = i18n( "Data has been changed externally. Unsaved "
1508 "changes will be lost." ); 1508 "changes will be lost." );
1509 KMessageBox::information( this, text ); 1509 KMessageBox::information( this, text );
1510 } 1510 }
1511 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1511 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1512 ++it; 1512 ++it;
1513 } 1513 }
1514*/ 1514*/
1515 if (mEditorDialog) 1515 if (mEditorDialog)
1516 { 1516 {
1517 if (mEditorDialog->dirty()) 1517 if (mEditorDialog->dirty())
1518 { 1518 {
1519 QString text = i18n( "Data has been changed externally. Unsaved " 1519 QString text = i18n( "Data has been changed externally. Unsaved "
1520 "changes will be lost." ); 1520 "changes will be lost." );
1521 KMessageBox::information( this, text ); 1521 KMessageBox::information( this, text );
1522 } 1522 }
1523 QString currentuid = mEditorDialog->addressee().uid(); 1523 QString currentuid = mEditorDialog->addressee().uid();
1524 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1524 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1525 } 1525 }
1526 mViewManager->refreshView(); 1526 mViewManager->refreshView();
1527// mDetails->refreshView(); 1527// mDetails->refreshView();
1528 1528
1529 1529
1530} 1530}
1531 1531
1532AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1532AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1533 const char *name ) 1533 const char *name )
1534{ 1534{
1535 1535
1536 if ( mEditorDialog == 0 ) { 1536 if ( mEditorDialog == 0 ) {
1537 mEditorDialog = new AddresseeEditorDialog( this, parent, 1537 mEditorDialog = new AddresseeEditorDialog( this, parent,
1538 name ? name : "editorDialog" ); 1538 name ? name : "editorDialog" );
1539 1539
1540 1540
1541 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1541 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1542 SLOT( contactModified( const KABC::Addressee& ) ) ); 1542 SLOT( contactModified( const KABC::Addressee& ) ) );
1543 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1543 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1544 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1544 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1545 } 1545 }
1546 1546
1547 return mEditorDialog; 1547 return mEditorDialog;
1548} 1548}
1549 1549
1550void KABCore::slotEditorDestroyed( const QString &uid ) 1550void KABCore::slotEditorDestroyed( const QString &uid )
1551{ 1551{
1552 //mEditorDict.remove( uid ); 1552 //mEditorDict.remove( uid );
1553} 1553}
1554 1554
1555void KABCore::initGUI() 1555void KABCore::initGUI()
1556{ 1556{
1557#ifndef KAB_EMBEDDED 1557#ifndef KAB_EMBEDDED
1558 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1558 QHBoxLayout *topLayout = new QHBoxLayout( this );
1559 topLayout->setSpacing( KDialogBase::spacingHint() ); 1559 topLayout->setSpacing( KDialogBase::spacingHint() );
1560 1560
1561 mExtensionBarSplitter = new QSplitter( this ); 1561 mExtensionBarSplitter = new QSplitter( this );
1562 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1562 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1563 1563
1564 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1564 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1565 1565
1566 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1566 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1567 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1567 mIncSearchWidget = new IncSearchWidget( viewSpace );
1568 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1568 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1569 SLOT( incrementalSearch( const QString& ) ) ); 1569 SLOT( incrementalSearch( const QString& ) ) );
1570 1570
1571 mViewManager = new ViewManager( this, viewSpace ); 1571 mViewManager = new ViewManager( this, viewSpace );
1572 viewSpace->setStretchFactor( mViewManager, 1 ); 1572 viewSpace->setStretchFactor( mViewManager, 1 );
1573 1573
1574 mDetails = new ViewContainer( mDetailsSplitter ); 1574 mDetails = new ViewContainer( mDetailsSplitter );
1575 1575
1576 mJumpButtonBar = new JumpButtonBar( this, this ); 1576 mJumpButtonBar = new JumpButtonBar( this, this );
1577 1577
1578 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1578 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1579 1579
1580 topLayout->addWidget( mExtensionBarSplitter ); 1580 topLayout->addWidget( mExtensionBarSplitter );
1581 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1581 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1582 topLayout->addWidget( mJumpButtonBar ); 1582 topLayout->addWidget( mJumpButtonBar );
1583 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1583 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1584 1584
1585 mXXPortManager = new XXPortManager( this, this ); 1585 mXXPortManager = new XXPortManager( this, this );
1586 1586
1587#else //KAB_EMBEDDED 1587#else //KAB_EMBEDDED
1588 //US initialize viewMenu before settingup viewmanager. 1588 //US initialize viewMenu before settingup viewmanager.
1589 // Viewmanager needs this menu to plugin submenues. 1589 // Viewmanager needs this menu to plugin submenues.
1590 viewMenu = new QPopupMenu( this ); 1590 viewMenu = new QPopupMenu( this );
1591 settingsMenu = new QPopupMenu( this ); 1591 settingsMenu = new QPopupMenu( this );
1592 //filterMenu = new QPopupMenu( this ); 1592 //filterMenu = new QPopupMenu( this );
1593 ImportMenu = new QPopupMenu( this ); 1593 ImportMenu = new QPopupMenu( this );
1594 ExportMenu = new QPopupMenu( this ); 1594 ExportMenu = new QPopupMenu( this );
1595 syncMenu = new QPopupMenu( this ); 1595 syncMenu = new QPopupMenu( this );
1596 changeMenu= new QPopupMenu( this ); 1596 changeMenu= new QPopupMenu( this );
1597 1597
1598//US since we have no splitter for the embedded system, setup 1598//US since we have no splitter for the embedded system, setup
1599// a layout with two frames. One left and one right. 1599// a layout with two frames. One left and one right.
1600 1600
1601 QBoxLayout *topLayout; 1601 QBoxLayout *topLayout;
1602 1602
1603 // = new QHBoxLayout( this ); 1603 // = new QHBoxLayout( this );
1604// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1604// QBoxLayout *topLayout = (QBoxLayout*)layout();
1605 1605
1606// QWidget *mainBox = new QWidget( this ); 1606// QWidget *mainBox = new QWidget( this );
1607// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1607// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1608 1608
1609#ifdef DESKTOP_VERSION 1609#ifdef DESKTOP_VERSION
1610 topLayout = new QHBoxLayout( this ); 1610 topLayout = new QHBoxLayout( this );
1611 1611
1612 1612
1613 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1613 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1614 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1614 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1615 1615
1616 topLayout->addWidget(mMiniSplitter ); 1616 topLayout->addWidget(mMiniSplitter );
1617 1617
1618 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1618 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1619 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1619 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1620 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1620 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1621 mDetails = new ViewContainer( mMiniSplitter ); 1621 mDetails = new ViewContainer( mMiniSplitter );
1622 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1622 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1623#else 1623#else
1624 if ( QApplication::desktop()->width() > 480 ) { 1624 if ( QApplication::desktop()->width() > 480 ) {
1625 topLayout = new QHBoxLayout( this ); 1625 topLayout = new QHBoxLayout( this );
1626 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1626 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1627 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1627 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1628 } else { 1628 } else {
1629 1629
1630 topLayout = new QHBoxLayout( this ); 1630 topLayout = new QHBoxLayout( this );
1631 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1631 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1632 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1632 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1633 } 1633 }
1634 1634
1635 topLayout->addWidget(mMiniSplitter ); 1635 topLayout->addWidget(mMiniSplitter );
1636 mViewManager = new ViewManager( this, mMiniSplitter ); 1636 mViewManager = new ViewManager( this, mMiniSplitter );
1637 mDetails = new ViewContainer( mMiniSplitter ); 1637 mDetails = new ViewContainer( mMiniSplitter );
1638 1638
1639 1639
1640 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1640 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1641#endif 1641#endif
1642 //eh->hide(); 1642 //eh->hide();
1643 // topLayout->addWidget(mExtensionManager ); 1643 // topLayout->addWidget(mExtensionManager );
1644 1644
1645 1645
1646/*US 1646/*US
1647#ifndef KAB_NOSPLITTER 1647#ifndef KAB_NOSPLITTER
1648 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1648 QHBoxLayout *topLayout = new QHBoxLayout( this );
1649//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1649//US topLayout->setSpacing( KDialogBase::spacingHint() );
1650 topLayout->setSpacing( 10 ); 1650 topLayout->setSpacing( 10 );
1651 1651
1652 mDetailsSplitter = new QSplitter( this ); 1652 mDetailsSplitter = new QSplitter( this );
1653 1653
1654 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1654 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1655 1655
1656 mViewManager = new ViewManager( this, viewSpace ); 1656 mViewManager = new ViewManager( this, viewSpace );
1657 viewSpace->setStretchFactor( mViewManager, 1 ); 1657 viewSpace->setStretchFactor( mViewManager, 1 );
1658 1658
1659 mDetails = new ViewContainer( mDetailsSplitter ); 1659 mDetails = new ViewContainer( mDetailsSplitter );
1660 1660
1661 topLayout->addWidget( mDetailsSplitter ); 1661 topLayout->addWidget( mDetailsSplitter );
1662 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1662 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1663#else //KAB_NOSPLITTER 1663#else //KAB_NOSPLITTER
1664 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1664 QHBoxLayout *topLayout = new QHBoxLayout( this );
1665//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1665//US topLayout->setSpacing( KDialogBase::spacingHint() );
1666 topLayout->setSpacing( 10 ); 1666 topLayout->setSpacing( 10 );
1667 1667
1668// mDetailsSplitter = new QSplitter( this ); 1668// mDetailsSplitter = new QSplitter( this );
1669 1669
1670 QVBox *viewSpace = new QVBox( this ); 1670 QVBox *viewSpace = new QVBox( this );
1671 1671
1672 mViewManager = new ViewManager( this, viewSpace ); 1672 mViewManager = new ViewManager( this, viewSpace );
1673 viewSpace->setStretchFactor( mViewManager, 1 ); 1673 viewSpace->setStretchFactor( mViewManager, 1 );
1674 1674
1675 mDetails = new ViewContainer( this ); 1675 mDetails = new ViewContainer( this );
1676 1676
1677 topLayout->addWidget( viewSpace ); 1677 topLayout->addWidget( viewSpace );
1678// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1678// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1679 topLayout->addWidget( mDetails ); 1679 topLayout->addWidget( mDetails );
1680#endif //KAB_NOSPLITTER 1680#endif //KAB_NOSPLITTER
1681*/ 1681*/
1682 1682
1683 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1683 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1684 syncManager->setBlockSave(false); 1684 syncManager->setBlockSave(false);
1685 1685
1686 connect(syncManager , SIGNAL( save() ), this, SLOT( save() ) );
1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1688 syncManager->setDefaultFileName(locateLocal( "apps","kabc/std.vcf") );
1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1686 1690
1687#endif //KAB_EMBEDDED 1691#endif //KAB_EMBEDDED
1688 initActions(); 1692 initActions();
1689 1693
1690#ifdef KAB_EMBEDDED 1694#ifdef KAB_EMBEDDED
1691 addActionsManually(); 1695 addActionsManually();
1692 //US make sure the export and import menues are initialized before creating the xxPortManager. 1696 //US make sure the export and import menues are initialized before creating the xxPortManager.
1693 mXXPortManager = new XXPortManager( this, this ); 1697 mXXPortManager = new XXPortManager( this, this );
1694 1698
1695 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1696 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1697 // mActionQuit->plug ( mMainWindow->toolBar()); 1701 // mActionQuit->plug ( mMainWindow->toolBar());
1698 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1699 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1700 // mIncSearchWidget->hide(); 1704 // mIncSearchWidget->hide();
1701 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1705 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1702 SLOT( incrementalSearch( const QString& ) ) ); 1706 SLOT( incrementalSearch( const QString& ) ) );
1703 1707
1704 1708
1705 mJumpButtonBar = new JumpButtonBar( this, this ); 1709 mJumpButtonBar = new JumpButtonBar( this, this );
1706 1710
1707 topLayout->addWidget( mJumpButtonBar ); 1711 topLayout->addWidget( mJumpButtonBar );
1708//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1712//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1709 1713
1710// mMainWindow->getIconToolBar()->raise(); 1714// mMainWindow->getIconToolBar()->raise();
1711 1715
1712#endif //KAB_EMBEDDED 1716#endif //KAB_EMBEDDED
1713 1717
1714} 1718}
1715void KABCore::initActions() 1719void KABCore::initActions()
1716{ 1720{
1717//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1721//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1718 1722
1719#ifndef KAB_EMBEDDED 1723#ifndef KAB_EMBEDDED
1720 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1724 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1721 SLOT( clipboardDataChanged() ) ); 1725 SLOT( clipboardDataChanged() ) );
1722#endif //KAB_EMBEDDED 1726#endif //KAB_EMBEDDED
1723 1727
1724 // file menu 1728 // file menu
1725 if ( mIsPart ) { 1729 if ( mIsPart ) {
1726 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1730 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1727 SLOT( sendMail() ), actionCollection(), 1731 SLOT( sendMail() ), actionCollection(),
1728 "kaddressbook_mail" ); 1732 "kaddressbook_mail" );
1729 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1733 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1730 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1734 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1731 1735
1732 } else { 1736 } else {
1733 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1737 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1734 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1738 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1735 } 1739 }
1736 1740
1737 1741
1738 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1742 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1739 SLOT( save() ), actionCollection(), "file_sync" ); 1743 SLOT( save() ), actionCollection(), "file_sync" );
1740 1744
1741 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1745 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1742 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1746 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1743 1747
1744 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1748 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1745 this, SLOT( mailVCard() ), 1749 this, SLOT( mailVCard() ),
1746 actionCollection(), "file_mail_vcard"); 1750 actionCollection(), "file_mail_vcard");
1747 1751
1748 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1752 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1749 SLOT( export2phone() ), actionCollection(), 1753 SLOT( export2phone() ), actionCollection(),
1750 "kaddressbook_ex2phone" ); 1754 "kaddressbook_ex2phone" );
1751 1755
1752 mActionBeamVCard = 0; 1756 mActionBeamVCard = 0;
1753 mActionBeam = 0; 1757 mActionBeam = 0;
1754 1758
1755#ifndef DESKTOP_VERSION 1759#ifndef DESKTOP_VERSION
1756 if ( Ir::supported() ) { 1760 if ( Ir::supported() ) {
1757 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1761 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1758 SLOT( beamVCard() ), actionCollection(), 1762 SLOT( beamVCard() ), actionCollection(),
1759 "kaddressbook_beam_vcard" ); 1763 "kaddressbook_beam_vcard" );
1760 1764
1761 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1765 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1762 SLOT( beamMySelf() ), actionCollection(), 1766 SLOT( beamMySelf() ), actionCollection(),
1763 "kaddressbook_beam_myself" ); 1767 "kaddressbook_beam_myself" );
1764 } 1768 }
1765#endif 1769#endif
1766 1770
1767 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1771 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1768 this, SLOT( editContact2() ), 1772 this, SLOT( editContact2() ),
1769 actionCollection(), "file_properties" ); 1773 actionCollection(), "file_properties" );
1770 1774
1771#ifdef KAB_EMBEDDED 1775#ifdef KAB_EMBEDDED
1772 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1776 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1773 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1777 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1774 mMainWindow, SLOT( exit() ), 1778 mMainWindow, SLOT( exit() ),
1775 actionCollection(), "quit" ); 1779 actionCollection(), "quit" );
1776#endif //KAB_EMBEDDED 1780#endif //KAB_EMBEDDED
1777 1781
1778 // edit menu 1782 // edit menu
1779 if ( mIsPart ) { 1783 if ( mIsPart ) {
1780 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1784 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1781 SLOT( copyContacts() ), actionCollection(), 1785 SLOT( copyContacts() ), actionCollection(),
1782 "kaddressbook_copy" ); 1786 "kaddressbook_copy" );
1783 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1787 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1784 SLOT( cutContacts() ), actionCollection(), 1788 SLOT( cutContacts() ), actionCollection(),
1785 "kaddressbook_cut" ); 1789 "kaddressbook_cut" );
1786 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1790 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1787 SLOT( pasteContacts() ), actionCollection(), 1791 SLOT( pasteContacts() ), actionCollection(),
1788 "kaddressbook_paste" ); 1792 "kaddressbook_paste" );
1789 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1793 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1790 SLOT( selectAllContacts() ), actionCollection(), 1794 SLOT( selectAllContacts() ), actionCollection(),
1791 "kaddressbook_select_all" ); 1795 "kaddressbook_select_all" );
1792 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1796 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1793 SLOT( undo() ), actionCollection(), 1797 SLOT( undo() ), actionCollection(),
1794 "kaddressbook_undo" ); 1798 "kaddressbook_undo" );
1795 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1799 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1796 this, SLOT( redo() ), actionCollection(), 1800 this, SLOT( redo() ), actionCollection(),
1797 "kaddressbook_redo" ); 1801 "kaddressbook_redo" );
1798 } else { 1802 } else {
1799 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1803 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1800 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1804 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1801 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1805 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1802 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1806 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1803 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1807 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1804 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1808 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1805 } 1809 }
1806 1810
1807 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1811 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1808 Key_Delete, this, SLOT( deleteContacts() ), 1812 Key_Delete, this, SLOT( deleteContacts() ),
1809 actionCollection(), "edit_delete" ); 1813 actionCollection(), "edit_delete" );
1810 1814
1811 mActionUndo->setEnabled( false ); 1815 mActionUndo->setEnabled( false );
1812 mActionRedo->setEnabled( false ); 1816 mActionRedo->setEnabled( false );
1813 1817
1814 // settings menu 1818 // settings menu
1815#ifdef KAB_EMBEDDED 1819#ifdef KAB_EMBEDDED
1816//US special menuentry to configure the addressbook resources. On KDE 1820//US special menuentry to configure the addressbook resources. On KDE
1817// you do that through the control center !!! 1821// you do that through the control center !!!
1818 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1822 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1819 SLOT( configureResources() ), actionCollection(), 1823 SLOT( configureResources() ), actionCollection(),
1820 "kaddressbook_configure_resources" ); 1824 "kaddressbook_configure_resources" );
1821#endif //KAB_EMBEDDED 1825#endif //KAB_EMBEDDED
1822 1826
1823 if ( mIsPart ) { 1827 if ( mIsPart ) {
1824 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1828 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1825 SLOT( openConfigDialog() ), actionCollection(), 1829 SLOT( openConfigDialog() ), actionCollection(),
1826 "kaddressbook_configure" ); 1830 "kaddressbook_configure" );
1827 1831
1828 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1832 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1829 this, SLOT( configureKeyBindings() ), actionCollection(), 1833 this, SLOT( configureKeyBindings() ), actionCollection(),
1830 "kaddressbook_configure_shortcuts" ); 1834 "kaddressbook_configure_shortcuts" );
1831#ifdef KAB_EMBEDDED 1835#ifdef KAB_EMBEDDED
1832 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1833 mActionConfigureToolbars->setEnabled( false ); 1837 mActionConfigureToolbars->setEnabled( false );
1834#endif //KAB_EMBEDDED 1838#endif //KAB_EMBEDDED
1835 1839
1836 } else { 1840 } else {
1837 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1838 1842
1839 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1843 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1840 } 1844 }
1841 1845
1842 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1846 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1843 actionCollection(), "options_show_jump_bar" ); 1847 actionCollection(), "options_show_jump_bar" );
1844 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1848 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1845 1849
1846 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1850 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1847 actionCollection(), "options_show_details" ); 1851 actionCollection(), "options_show_details" );
1848 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1852 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1849 1853
1850 // misc 1854 // misc
1851 // only enable LDAP lookup if we can handle the protocol 1855 // only enable LDAP lookup if we can handle the protocol
1852#ifndef KAB_EMBEDDED 1856#ifndef KAB_EMBEDDED
1853 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1857 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1854 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1858 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1855 this, SLOT( openLDAPDialog() ), actionCollection(), 1859 this, SLOT( openLDAPDialog() ), actionCollection(),
1856 "ldap_lookup" ); 1860 "ldap_lookup" );
1857 } 1861 }
1858#else //KAB_EMBEDDED 1862#else //KAB_EMBEDDED
1859 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1863 //qDebug("KABCore::initActions() LDAP has to be implemented");
1860#endif //KAB_EMBEDDED 1864#endif //KAB_EMBEDDED
1861 1865
1862 1866
1863 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1867 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1864 SLOT( setWhoAmI() ), actionCollection(), 1868 SLOT( setWhoAmI() ), actionCollection(),
1865 "set_personal" ); 1869 "set_personal" );
1866 1870
1867 1871
1868 1872
1869 1873
1870 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1874 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1871 SLOT( setCategories() ), actionCollection(), 1875 SLOT( setCategories() ), actionCollection(),
1872 "edit_set_categories" ); 1876 "edit_set_categories" );
1873 1877
1874 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1878 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1875 SLOT( removeVoice() ), actionCollection(), 1879 SLOT( removeVoice() ), actionCollection(),
1876 "remove_voice" ); 1880 "remove_voice" );
1877 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1881 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
@@ -2648,229 +2652,220 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2648 } 2652 }
2649 ++incCounter; 2653 ++incCounter;
2650 } 2654 }
2651 er.clear(); 2655 er.clear();
2652 QStringList el = local->uidList(); 2656 QStringList el = local->uidList();
2653 modulo = (el.count()/10)+1; 2657 modulo = (el.count()/10)+1;
2654 2658
2655 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2659 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2656 incCounter = 0; 2660 incCounter = 0;
2657 while ( incCounter < el.count()) { 2661 while ( incCounter < el.count()) {
2658 qApp->processEvents(); 2662 qApp->processEvents();
2659 if (syncManager->isProgressBarCanceled()) 2663 if (syncManager->isProgressBarCanceled())
2660 return false; 2664 return false;
2661 if ( incCounter % modulo == 0 ) 2665 if ( incCounter % modulo == 0 )
2662 syncManager->showProgressBar(incCounter); 2666 syncManager->showProgressBar(incCounter);
2663 uid = el[ incCounter ]; 2667 uid = el[ incCounter ];
2664 bool skipIncidence = false; 2668 bool skipIncidence = false;
2665 if ( uid.left(19) == QString("last-syncAddressee-") ) 2669 if ( uid.left(19) == QString("last-syncAddressee-") )
2666 skipIncidence = true; 2670 skipIncidence = true;
2667 if ( !skipIncidence ) { 2671 if ( !skipIncidence ) {
2668 inL = local->findByUid( uid ); 2672 inL = local->findByUid( uid );
2669 inR = remote->findByUid( uid ); 2673 inR = remote->findByUid( uid );
2670 if ( inR.isEmpty() ) { 2674 if ( inR.isEmpty() ) {
2671 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2672 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2673 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2674 local->removeAddressee( inL ); 2678 local->removeAddressee( inL );
2675 ++deletedAddresseeL; 2679 ++deletedAddresseeL;
2676 } else { 2680 } else {
2677 if ( ! syncManager->mWriteBackExistingOnly ) { 2681 if ( ! syncManager->mWriteBackExistingOnly ) {
2678 inL.removeID(mCurrentSyncDevice ); 2682 inL.removeID(mCurrentSyncDevice );
2679 ++addedAddresseeR; 2683 ++addedAddresseeR;
2680 inL.setRevision( modifiedCalendar ); 2684 inL.setRevision( modifiedCalendar );
2681 local->insertAddressee( inL, false ); 2685 local->insertAddressee( inL, false );
2682 inR = inL; 2686 inR = inL;
2683 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2684 inR.setResource( 0 ); 2688 inR.setResource( 0 );
2685 remote->insertAddressee( inR, false ); 2689 remote->insertAddressee( inR, false );
2686 } 2690 }
2687 } 2691 }
2688 } else { 2692 } else {
2689 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2690 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2691 local->removeAddressee( inL ); 2695 local->removeAddressee( inL );
2692 ++deletedAddresseeL; 2696 ++deletedAddresseeL;
2693 } else { 2697 } else {
2694 if ( ! syncManager->mWriteBackExistingOnly ) { 2698 if ( ! syncManager->mWriteBackExistingOnly ) {
2695 ++addedAddresseeR; 2699 ++addedAddresseeR;
2696 inL.setRevision( modifiedCalendar ); 2700 inL.setRevision( modifiedCalendar );
2697 local->insertAddressee( inL, false ); 2701 local->insertAddressee( inL, false );
2698 inR = inL; 2702 inR = inL;
2699 inR.setResource( 0 ); 2703 inR.setResource( 0 );
2700 remote->insertAddressee( inR, false ); 2704 remote->insertAddressee( inR, false );
2701 } 2705 }
2702 } 2706 }
2703 } 2707 }
2704 } 2708 }
2705 } 2709 }
2706 ++incCounter; 2710 ++incCounter;
2707 } 2711 }
2708 el.clear(); 2712 el.clear();
2709 syncManager->hideProgressBar(); 2713 syncManager->hideProgressBar();
2710 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2711 // get rid of micro seconds 2715 // get rid of micro seconds
2712 QTime t = mLastAddressbookSync.time(); 2716 QTime t = mLastAddressbookSync.time();
2713 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2714 addresseeLSync.setRevision( mLastAddressbookSync ); 2718 addresseeLSync.setRevision( mLastAddressbookSync );
2715 addresseeRSync.setRevision( mLastAddressbookSync ); 2719 addresseeRSync.setRevision( mLastAddressbookSync );
2716 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2717 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2718 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2719 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2720 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2721 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2722 addresseeRSync.setNote( "" ) ; 2726 addresseeRSync.setNote( "" ) ;
2723 addresseeLSync.setNote( "" ); 2727 addresseeLSync.setNote( "" );
2724 2728
2725 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2726 remote->insertAddressee( addresseeRSync, false ); 2730 remote->insertAddressee( addresseeRSync, false );
2727 local->insertAddressee( addresseeLSync, false ); 2731 local->insertAddressee( addresseeLSync, false );
2728 QString mes; 2732 QString mes;
2729 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2733 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2730 if ( syncManager->mShowSyncSummary ) { 2734 if ( syncManager->mShowSyncSummary ) {
2731 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2732 } 2736 }
2733 qDebug( mes ); 2737 qDebug( mes );
2734 return syncOK; 2738 return syncOK;
2735} 2739}
2736 2740
2737 2741
2738//this is a overwritten callbackmethods from the syncinterface 2742//this is a overwritten callbackmethods from the syncinterface
2739bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2740{ 2744{
2741 2745
2742 //pending prepare addresseeview for output 2746 //pending prepare addresseeview for output
2743 //pending detect, if remote file has REV field. if not switch to external sync 2747 //pending detect, if remote file has REV field. if not switch to external sync
2744 mGlobalSyncMode = SYNC_MODE_NORMAL; 2748 mGlobalSyncMode = SYNC_MODE_NORMAL;
2745 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2746 2750
2747 AddressBook abLocal(filename,"syncContact"); 2751 AddressBook abLocal(filename,"syncContact");
2748 bool syncOK = false; 2752 bool syncOK = false;
2749 if ( abLocal.load() ) { 2753 if ( abLocal.load() ) {
2750 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2751 bool external = false; 2755 bool external = false;
2752 bool isXML = false; 2756 bool isXML = false;
2753 if ( filename.right(4) == ".xml") { 2757 if ( filename.right(4) == ".xml") {
2754 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2755 isXML = true; 2759 isXML = true;
2756 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2757 } else { 2761 } else {
2758 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2759 if ( ! lse.isEmpty() ) { 2763 if ( ! lse.isEmpty() ) {
2760 if ( lse.familyName().left(4) == "!E: " ) 2764 if ( lse.familyName().left(4) == "!E: " )
2761 external = true; 2765 external = true;
2762 } else { 2766 } else {
2763 bool found = false; 2767 bool found = false;
2764 AddressBook::Iterator it; 2768 AddressBook::Iterator it;
2765 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2766 if ( (*it).revision().date().year() > 2003 ) { 2770 if ( (*it).revision().date().year() > 2003 ) {
2767 found = true; 2771 found = true;
2768 break; 2772 break;
2769 } 2773 }
2770 } 2774 }
2771 external = ! found; 2775 external = ! found;
2772 } 2776 }
2773 2777
2774 if ( external ) { 2778 if ( external ) {
2775 qDebug("Setting vcf mode to external "); 2779 qDebug("Setting vcf mode to external ");
2776 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2777 AddressBook::Iterator it; 2781 AddressBook::Iterator it;
2778 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2779 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2783 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2780 (*it).computeCsum( mCurrentSyncDevice ); 2784 (*it).computeCsum( mCurrentSyncDevice );
2781 } 2785 }
2782 } 2786 }
2783 } 2787 }
2784 //AddressBook::Iterator it; 2788 //AddressBook::Iterator it;
2785 //QStringList vcards; 2789 //QStringList vcards;
2786 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2787 // qDebug("Name %s ", (*it).familyName().latin1()); 2791 // qDebug("Name %s ", (*it).familyName().latin1());
2788 //} 2792 //}
2789 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2790 if ( syncOK ) { 2794 if ( syncOK ) {
2791 if ( syncManager->mWriteBackFile ) 2795 if ( syncManager->mWriteBackFile )
2792 { 2796 {
2793 if ( external ) 2797 if ( external )
2794 abLocal.removeSyncAddressees( !isXML); 2798 abLocal.removeSyncAddressees( !isXML);
2795 qDebug("Saving remote AB "); 2799 qDebug("Saving remote AB ");
2796 abLocal.saveAB(); 2800 abLocal.saveAB();
2797 if ( isXML ) { 2801 if ( isXML ) {
2798 // afterwrite processing 2802 // afterwrite processing
2799 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2800 } 2804 }
2801 } 2805 }
2802 } 2806 }
2803 setModified(); 2807 setModified();
2804 2808
2805 } 2809 }
2806 if ( syncOK ) 2810 if ( syncOK )
2807 mViewManager->refreshView(); 2811 mViewManager->refreshView();
2808 return syncOK; 2812 return syncOK;
2809#if 0 2813#if 0
2810 2814
2811 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2812 getEventViewerDialog()->setSyncMode( true ); 2816 getEventViewerDialog()->setSyncMode( true );
2813 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2814 getEventViewerDialog()->setSyncMode( false ); 2818 getEventViewerDialog()->setSyncMode( false );
2815 if ( syncOK ) { 2819 if ( syncOK ) {
2816 if ( KOPrefs::instance()->mWriteBackFile ) 2820 if ( KOPrefs::instance()->mWriteBackFile )
2817 { 2821 {
2818 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2819 storage->save(); 2823 storage->save();
2820 } 2824 }
2821 } 2825 }
2822 setModified(); 2826 setModified();
2823 } 2827 }
2824 2828
2825#endif 2829#endif
2826} 2830}
2827 2831
2828 2832
2829//this is a overwritten callbackmethods from the syncinterface 2833//this is a overwritten callbackmethods from the syncinterface
2830bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2834bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2831{ 2835{
2832 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2833 2837
2834 AddressBook abLocal( resource,"syncContact"); 2838 AddressBook abLocal( resource,"syncContact");
2835 bool syncOK = false; 2839 bool syncOK = false;
2836 if ( abLocal.load() ) { 2840 if ( abLocal.load() ) {
2837 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2838 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2839 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2840 qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? ");
2841 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2842 if ( syncOK ) { 2845 if ( syncOK ) {
2843 if ( syncManager->mWriteBackFile ) { 2846 if ( syncManager->mWriteBackFile ) {
2844 abLocal.saveAB(); 2847 abLocal.saveAB();
2845 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2846 } 2849 }
2847 } 2850 }
2848 setModified(); 2851 setModified();
2849 } 2852 }
2850 if ( syncOK ) 2853 if ( syncOK )
2851 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2852 return syncOK; 2855 return syncOK;
2853 2856
2854} 2857}
2855 2858
2856//called by the syncmanager to indicate that the work has to marked as dirty. 2859void KABCore::getFile( bool success )
2857void KABCore::sync_setModified()
2858{ 2860{
2859 setModified(); 2861 if ( ! success ) {
2860} 2862 setCaption( i18n("Error receiving file. Nothing changed!") );
2861 2863 return;
2862//called by the syncmanager to ask if the dirty flag is set. 2864 }
2863bool KABCore::sync_isModified() 2865 //mView->watchSavedFile();
2864{ 2866 //mView->openCalendar( defaultFileName() );
2865 return mModified; 2867 // pending: reload received file!
2866} 2868 setCaption( i18n("Pi-Sync successful!") );
2867
2868
2869//called by the syncmanager to indicate that the work has to be saved.
2870void KABCore::sync_save()
2871{
2872 save();
2873} 2869}
2874 2870
2875 2871
2876
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index c9c0d38..355e828 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -153,332 +153,327 @@ class KABCore : public QWidget, public KSyncInterface
153 void setContactSelected( const QString &uid ); 153 void setContactSelected( const QString &uid );
154 154
155 /** 155 /**
156 Opens the preferred mail composer with all selected contacts as 156 Opens the preferred mail composer with all selected contacts as
157 arguments. 157 arguments.
158 */ 158 */
159 void sendMail(); 159 void sendMail();
160 160
161 /** 161 /**
162 Opens the preferred mail composer with the given contacts as 162 Opens the preferred mail composer with the given contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail( const QString& email ); 165 void sendMail( const QString& email );
166 166
167 167
168 void mailVCard(); 168 void mailVCard();
169 void mailVCard(const QStringList& uids); 169 void mailVCard(const QStringList& uids);
170 170
171 /** 171 /**
172 Beams the "WhoAmI contact. 172 Beams the "WhoAmI contact.
173 */ 173 */
174 void beamMySelf(); 174 void beamMySelf();
175 175
176 void beamVCard(); 176 void beamVCard();
177 void export2phone(); 177 void export2phone();
178 void beamVCard(const QStringList& uids); 178 void beamVCard(const QStringList& uids);
179 void beamDone( Ir *ir ); 179 void beamDone( Ir *ir );
180 180
181 181
182 /** 182 /**
183 Starts the preferred web browser with the given URL as argument. 183 Starts the preferred web browser with the given URL as argument.
184 */ 184 */
185 void browse( const QString& url ); 185 void browse( const QString& url );
186 186
187 /** 187 /**
188 Select all contacts in the view. 188 Select all contacts in the view.
189 */ 189 */
190 void selectAllContacts(); 190 void selectAllContacts();
191 191
192 /** 192 /**
193 Deletes all selected contacts from the address book. 193 Deletes all selected contacts from the address book.
194 */ 194 */
195 void deleteContacts(); 195 void deleteContacts();
196 196
197 /** 197 /**
198 Deletes given contacts from the address book. 198 Deletes given contacts from the address book.
199 199
200 @param uids The uids of the contacts, which shall be deleted. 200 @param uids The uids of the contacts, which shall be deleted.
201 */ 201 */
202 void deleteContacts( const QStringList &uids ); 202 void deleteContacts( const QStringList &uids );
203 203
204 /** 204 /**
205 Copys the selected contacts into clipboard for later pasting. 205 Copys the selected contacts into clipboard for later pasting.
206 */ 206 */
207 void copyContacts(); 207 void copyContacts();
208 208
209 /** 209 /**
210 Cuts the selected contacts and stores them for later pasting. 210 Cuts the selected contacts and stores them for later pasting.
211 */ 211 */
212 void cutContacts(); 212 void cutContacts();
213 213
214 /** 214 /**
215 Paste contacts from clipboard into the address book. 215 Paste contacts from clipboard into the address book.
216 */ 216 */
217 void pasteContacts(); 217 void pasteContacts();
218 218
219 /** 219 /**
220 Paste given contacts into the address book. 220 Paste given contacts into the address book.
221 221
222 @param list The list of addressee, which shall be pasted. 222 @param list The list of addressee, which shall be pasted.
223 */ 223 */
224 void pasteContacts( KABC::Addressee::List &list ); 224 void pasteContacts( KABC::Addressee::List &list );
225 225
226 /** 226 /**
227 Sets the whoAmI contact, that is used by many other programs to 227 Sets the whoAmI contact, that is used by many other programs to
228 get personal information about the current user. 228 get personal information about the current user.
229 */ 229 */
230 void setWhoAmI(); 230 void setWhoAmI();
231 231
232 /** 232 /**
233 Displays the category dialog and applies the result to all 233 Displays the category dialog and applies the result to all
234 selected contacts. 234 selected contacts.
235 */ 235 */
236 void setCategories(); 236 void setCategories();
237 237
238 /** 238 /**
239 Sets the field list of the Incremental Search Widget. 239 Sets the field list of the Incremental Search Widget.
240 */ 240 */
241 void setSearchFields( const KABC::Field::List &fields ); 241 void setSearchFields( const KABC::Field::List &fields );
242 242
243 /** 243 /**
244 Search with the current search field for a contact, that matches 244 Search with the current search field for a contact, that matches
245 the given text, and selects it in the view. 245 the given text, and selects it in the view.
246 */ 246 */
247 void incrementalSearch( const QString& text ); 247 void incrementalSearch( const QString& text );
248 248
249 /** 249 /**
250 Marks the address book as modified. 250 Marks the address book as modified.
251 */ 251 */
252 void setModified(); 252 void setModified();
253 /** 253 /**
254 Marks the address book as modified without refreshing the view. 254 Marks the address book as modified without refreshing the view.
255 */ 255 */
256 void setModifiedWOrefresh(); 256 void setModifiedWOrefresh();
257 257
258 /** 258 /**
259 Marks the address book as modified concerning the argument. 259 Marks the address book as modified concerning the argument.
260 */ 260 */
261 void setModified( bool modified ); 261 void setModified( bool modified );
262 262
263 /** 263 /**
264 Returns whether the address book is modified. 264 Returns whether the address book is modified.
265 */ 265 */
266 bool modified() const; 266 bool modified() const;
267 267
268 /** 268 /**
269 Called whenever an contact is modified in the contact editor 269 Called whenever an contact is modified in the contact editor
270 dialog or the quick edit. 270 dialog or the quick edit.
271 */ 271 */
272 void contactModified( const KABC::Addressee &addr ); 272 void contactModified( const KABC::Addressee &addr );
273 273
274 /** 274 /**
275 DCOP METHODS. 275 DCOP METHODS.
276 */ 276 */
277 void addEmail( QString addr ); 277 void addEmail( QString addr );
278 void importVCard( const KURL& url, bool showPreview ); 278 void importVCard( const KURL& url, bool showPreview );
279 void importVCard( const QString& vCard, bool showPreview ); 279 void importVCard( const QString& vCard, bool showPreview );
280 void newContact(); 280 void newContact();
281 QString getNameByPhone( const QString& phone ); 281 QString getNameByPhone( const QString& phone );
282 /** 282 /**
283 END DCOP METHODS 283 END DCOP METHODS
284 */ 284 */
285 285
286 /** 286 /**
287 Saves the contents of the AddressBook back to disk. 287 Saves the contents of the AddressBook back to disk.
288 */ 288 */
289 void save(); 289 void save();
290 290
291 /** 291 /**
292 Undos the last command using the undo stack. 292 Undos the last command using the undo stack.
293 */ 293 */
294 void undo(); 294 void undo();
295 295
296 /** 296 /**
297 Redos the last command that was undone, using the redo stack. 297 Redos the last command that was undone, using the redo stack.
298 */ 298 */
299 void redo(); 299 void redo();
300 300
301 /** 301 /**
302 Shows the edit dialog for the given uid. If the uid is QString::null, 302 Shows the edit dialog for the given uid. If the uid is QString::null,
303 the method will try to find a selected addressee in the view. 303 the method will try to find a selected addressee in the view.
304 */ 304 */
305 void editContact( const QString &uid /*US = QString::null*/ ); 305 void editContact( const QString &uid /*US = QString::null*/ );
306//US added a second method without defaultparameter 306//US added a second method without defaultparameter
307 void editContact2(); 307 void editContact2();
308 308
309 /** 309 /**
310 Shows or edits the detail view for the given uid. If the uid is QString::null, 310 Shows or edits the detail view for the given uid. If the uid is QString::null,
311 the method will try to find a selected addressee in the view. 311 the method will try to find a selected addressee in the view.
312 */ 312 */
313 void executeContact( const QString &uid /*US = QString::null*/ ); 313 void executeContact( const QString &uid /*US = QString::null*/ );
314 314
315 /** 315 /**
316 Launches the configuration dialog. 316 Launches the configuration dialog.
317 */ 317 */
318 void openConfigDialog(); 318 void openConfigDialog();
319 319
320 /** 320 /**
321 Launches the ldap search dialog. 321 Launches the ldap search dialog.
322 */ 322 */
323 void openLDAPDialog(); 323 void openLDAPDialog();
324 324
325 /** 325 /**
326 Creates a KAddressBookPrinter, which will display the print 326 Creates a KAddressBookPrinter, which will display the print
327 dialog and do the printing. 327 dialog and do the printing.
328 */ 328 */
329 void print(); 329 void print();
330 330
331 /** 331 /**
332 Registers a new GUI client, so plugins can register its actions. 332 Registers a new GUI client, so plugins can register its actions.
333 */ 333 */
334 void addGUIClient( KXMLGUIClient *client ); 334 void addGUIClient( KXMLGUIClient *client );
335 335
336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
339 339
340 340
341 signals: 341 signals:
342 void contactSelected( const QString &name ); 342 void contactSelected( const QString &name );
343 void contactSelected( const QPixmap &pixmap ); 343 void contactSelected( const QPixmap &pixmap );
344 public slots: 344 public slots:
345 void getFile( bool success );
345 void setDetailsVisible( bool visible ); 346 void setDetailsVisible( bool visible );
346 void setDetailsToState(); 347 void setDetailsToState();
347 // void slotSyncMenu( int ); 348 // void slotSyncMenu( int );
348 private slots: 349 private slots:
349 void setJumpButtonBarVisible( bool visible ); 350 void setJumpButtonBarVisible( bool visible );
350 void importFromOL(); 351 void importFromOL();
351 void extensionModified( const KABC::Addressee::List &list ); 352 void extensionModified( const KABC::Addressee::List &list );
352 void extensionChanged( int id ); 353 void extensionChanged( int id );
353 void clipboardDataChanged(); 354 void clipboardDataChanged();
354 void updateActionMenu(); 355 void updateActionMenu();
355 void configureKeyBindings(); 356 void configureKeyBindings();
356 void removeVoice(); 357 void removeVoice();
357#ifdef KAB_EMBEDDED 358#ifdef KAB_EMBEDDED
358 void configureResources(); 359 void configureResources();
359#endif //KAB_EMBEDDED 360#endif //KAB_EMBEDDED
360 361
361 void slotEditorDestroyed( const QString &uid ); 362 void slotEditorDestroyed( const QString &uid );
362 void configurationChanged(); 363 void configurationChanged();
363 void addressBookChanged(); 364 void addressBookChanged();
364 365
365 private: 366 private:
366 void initGUI(); 367 void initGUI();
367 void initActions(); 368 void initActions();
368 369
369 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 370 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
370 const char *name = 0 ); 371 const char *name = 0 );
371 372
372 KXMLGUIClient *mGUIClient; 373 KXMLGUIClient *mGUIClient;
373 374
374 KABC::AddressBook *mAddressBook; 375 KABC::AddressBook *mAddressBook;
375 376
376 ViewManager *mViewManager; 377 ViewManager *mViewManager;
377 // QSplitter *mDetailsSplitter; 378 // QSplitter *mDetailsSplitter;
378 KDGanttMinimizeSplitter *mExtensionBarSplitter; 379 KDGanttMinimizeSplitter *mExtensionBarSplitter;
379 ViewContainer *mDetails; 380 ViewContainer *mDetails;
380 KDGanttMinimizeSplitter* mMiniSplitter; 381 KDGanttMinimizeSplitter* mMiniSplitter;
381 XXPortManager *mXXPortManager; 382 XXPortManager *mXXPortManager;
382 JumpButtonBar *mJumpButtonBar; 383 JumpButtonBar *mJumpButtonBar;
383 IncSearchWidget *mIncSearchWidget; 384 IncSearchWidget *mIncSearchWidget;
384 ExtensionManager *mExtensionManager; 385 ExtensionManager *mExtensionManager;
385 386
386 KCMultiDialog *mConfigureDialog; 387 KCMultiDialog *mConfigureDialog;
387 388
388#ifndef KAB_EMBEDDED 389#ifndef KAB_EMBEDDED
389 LDAPSearchDialog *mLdapSearchDialog; 390 LDAPSearchDialog *mLdapSearchDialog;
390#endif //KAB_EMBEDDED 391#endif //KAB_EMBEDDED
391 // QDict<AddresseeEditorDialog> mEditorDict; 392 // QDict<AddresseeEditorDialog> mEditorDict;
392 AddresseeEditorDialog *mEditorDialog; 393 AddresseeEditorDialog *mEditorDialog;
393 bool mReadWrite; 394 bool mReadWrite;
394 bool mModified; 395 bool mModified;
395 bool mIsPart; 396 bool mIsPart;
396 bool mMultipleViewsAtOnce; 397 bool mMultipleViewsAtOnce;
397 398
398 399
399 //US file menu 400 //US file menu
400 KAction *mActionMail; 401 KAction *mActionMail;
401 KAction *mActionBeam; 402 KAction *mActionBeam;
402 KAction *mActionExport2phone; 403 KAction *mActionExport2phone;
403 KAction* mActionPrint; 404 KAction* mActionPrint;
404 KAction* mActionNewContact; 405 KAction* mActionNewContact;
405 KAction *mActionSave; 406 KAction *mActionSave;
406 KAction *mActionEditAddressee; 407 KAction *mActionEditAddressee;
407 KAction *mActionMailVCard; 408 KAction *mActionMailVCard;
408 KAction *mActionBeamVCard; 409 KAction *mActionBeamVCard;
409 410
410 KAction *mActionQuit; 411 KAction *mActionQuit;
411 412
412 //US edit menu 413 //US edit menu
413 KAction *mActionCopy; 414 KAction *mActionCopy;
414 KAction *mActionCut; 415 KAction *mActionCut;
415 KAction *mActionPaste; 416 KAction *mActionPaste;
416 KAction *mActionSelectAll; 417 KAction *mActionSelectAll;
417 KAction *mActionUndo; 418 KAction *mActionUndo;
418 KAction *mActionRedo; 419 KAction *mActionRedo;
419 KAction *mActionDelete; 420 KAction *mActionDelete;
420 421
421 //US settings menu 422 //US settings menu
422 KAction *mActionConfigResources; 423 KAction *mActionConfigResources;
423 KAction *mActionConfigKAddressbook; 424 KAction *mActionConfigKAddressbook;
424 KAction *mActionConfigShortcuts; 425 KAction *mActionConfigShortcuts;
425 KAction *mActionConfigureToolbars; 426 KAction *mActionConfigureToolbars;
426 KAction *mActionKeyBindings; 427 KAction *mActionKeyBindings;
427 KToggleAction *mActionJumpBar; 428 KToggleAction *mActionJumpBar;
428 KToggleAction *mActionDetails; 429 KToggleAction *mActionDetails;
429 KAction *mActionWhoAmI; 430 KAction *mActionWhoAmI;
430 KAction *mActionCategories; 431 KAction *mActionCategories;
431 KAction *mActionAboutKAddressbook; 432 KAction *mActionAboutKAddressbook;
432 KAction *mActionLicence; 433 KAction *mActionLicence;
433 KAction *mActionFaq; 434 KAction *mActionFaq;
434 435
435 KAction *mActionDeleteView; 436 KAction *mActionDeleteView;
436 437
437 QPopupMenu *viewMenu; 438 QPopupMenu *viewMenu;
438 QPopupMenu *filterMenu; 439 QPopupMenu *filterMenu;
439 QPopupMenu *settingsMenu; 440 QPopupMenu *settingsMenu;
440 QPopupMenu *changeMenu; 441 QPopupMenu *changeMenu;
441//US QAction *mActionSave; 442//US QAction *mActionSave;
442 QPopupMenu *ImportMenu; 443 QPopupMenu *ImportMenu;
443 QPopupMenu *ExportMenu; 444 QPopupMenu *ExportMenu;
444 //LR additional methods 445 //LR additional methods
445 KAction *mActionRemoveVoice; 446 KAction *mActionRemoveVoice;
446 KAction * mActionImportOL; 447 KAction * mActionImportOL;
447 448
448#ifndef KAB_EMBEDDED 449#ifndef KAB_EMBEDDED
449 KAddressBookService *mAddressBookService; 450 KAddressBookService *mAddressBookService;
450#endif //KAB_EMBEDDED 451#endif //KAB_EMBEDDED
451 452
452 class KABCorePrivate; 453 class KABCorePrivate;
453 KABCorePrivate *d; 454 KABCorePrivate *d;
454 //US bool mBlockSaveFlag; 455 //US bool mBlockSaveFlag;
455 456
456#ifdef KAB_EMBEDDED 457#ifdef KAB_EMBEDDED
457 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 458 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
458#endif //KAB_EMBEDDED 459#endif //KAB_EMBEDDED
459 460
460 //this are the overwritten callbackmethods from the syncinterface 461 //this are the overwritten callbackmethods from the syncinterface
461 virtual bool sync(KSyncManager* manager, QString filename, int mode); 462 virtual bool sync(KSyncManager* manager, QString filename, int mode);
462 virtual bool syncExternal(KSyncManager* manager, QString resource); 463 virtual bool syncExternal(KSyncManager* manager, QString resource);
463 464
464 //called by the syncmanager to indicate that the work has to marked as dirty.
465 virtual void sync_setModified();
466 //called by the syncmanager to ask if the dirty flag is set.
467 virtual bool sync_isModified();
468 //called by the syncmanager to indicate that the work has to be saved.
469 virtual void sync_save();
470 465
471 // LR ******************************* 466 // LR *******************************
472 // sync stuff! 467 // sync stuff!
473 QPopupMenu *syncMenu; 468 QPopupMenu *syncMenu;
474 KSyncManager* syncManager; 469 KSyncManager* syncManager;
475 int mGlobalSyncMode; 470 int mGlobalSyncMode;
476 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 471 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
477 KABC::Addressee getLastSyncAddressee(); 472 KABC::Addressee getLastSyncAddressee();
478 QDateTime mLastAddressbookSync; 473 QDateTime mLastAddressbookSync;
479 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 474 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
480 // ********************* 475 // *********************
481 476
482}; 477};
483 478
484#endif 479#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 84e3d00..1210094 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -3,386 +3,384 @@
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49const char *germanwords[][2] = { 49const char *germanwords[][2] = {
50#include "wordsgerman.h" 50#include "wordsgerman.h"
51 "", "" 51 "", ""
52}; 52};
53 53
54KOPrefs *KOPrefs::mInstance = 0; 54KOPrefs *KOPrefs::mInstance = 0;
55static KStaticDeleter<KOPrefs> insd; 55static KStaticDeleter<KOPrefs> insd;
56 56
57KOPrefs::KOPrefs() : 57KOPrefs::KOPrefs() :
58 KPimPrefs("korganizerrc") 58 KPimPrefs("korganizerrc")
59{ 59{
60 mCategoryColors.setAutoDelete(true); 60 mCategoryColors.setAutoDelete(true);
61 mLocaleDict = 0; 61 mLocaleDict = 0;
62 fillMailDefaults(); 62 fillMailDefaults();
63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
64 QColor defaultHolidayColor = QColor(255,0,0); 64 QColor defaultHolidayColor = QColor(255,0,0);
65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
68 QColor defaultTodoDueTodayColor = QColor(255,220,100); 68 QColor defaultTodoDueTodayColor = QColor(255,220,100);
69 QColor defaultTodoOverdueColor = QColor(255,153,125); 69 QColor defaultTodoOverdueColor = QColor(255,153,125);
70 70
71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
72 mDefaultViewFont = QFont("helvetica",10); 72 mDefaultViewFont = QFont("helvetica",10);
73 mDefaultMonthViewFont = QFont("helvetica",8); 73 mDefaultMonthViewFont = QFont("helvetica",8);
74 mMarcusBainsFont= QFont("helvetica",10); 74 mMarcusBainsFont= QFont("helvetica",10);
75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
76 mEditBoxFont = QFont("helvetica",12); 76 mEditBoxFont = QFont("helvetica",12);
77 mJornalViewFont = QFont("helvetica",12); 77 mJornalViewFont = QFont("helvetica",12);
78 78
79 KPrefs::setCurrentGroup("General"); 79 KPrefs::setCurrentGroup("General");
80 80
81 81
82 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 82 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
83 83
84 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 84 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
85 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 85 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
86 addItemBool("ShowIconSearch",&mShowIconSearch,true); 86 addItemBool("ShowIconSearch",&mShowIconSearch,true);
87 addItemBool("ShowIconList",&mShowIconList,true); 87 addItemBool("ShowIconList",&mShowIconList,true);
88 addItemBool("ShowIconDay1",&mShowIconDay1,true); 88 addItemBool("ShowIconDay1",&mShowIconDay1,true);
89 addItemBool("ShowIconDay5",&mShowIconDay5,true); 89 addItemBool("ShowIconDay5",&mShowIconDay5,true);
90 addItemBool("ShowIconDay7",&mShowIconDay7,true); 90 addItemBool("ShowIconDay7",&mShowIconDay7,true);
91 addItemBool("ShowIconMonth",&mShowIconMonth,true); 91 addItemBool("ShowIconMonth",&mShowIconMonth,true);
92 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 92 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
93 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 93 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
94 addItemBool("ShowIconBack",&mShowIconBack,true); 94 addItemBool("ShowIconBack",&mShowIconBack,true);
95 addItemBool("ShowIconToday",&mShowIconToday,true); 95 addItemBool("ShowIconToday",&mShowIconToday,true);
96 addItemBool("ShowIconForward",&mShowIconForward,true); 96 addItemBool("ShowIconForward",&mShowIconForward,true);
97 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 97 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
98 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 98 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
99 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 99 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
100 addItemBool("ShowIconNext",&mShowIconNext,true); 100 addItemBool("ShowIconNext",&mShowIconNext,true);
101 addItemBool("ShowIconJournal",&mShowIconJournal,true); 101 addItemBool("ShowIconJournal",&mShowIconJournal,true);
102 addItemBool("ShowIconStretch",&mShowIconStretch,true); 102 addItemBool("ShowIconStretch",&mShowIconStretch,true);
103 addItemBool("LanguageChanged",&mLanguageChanged,false); 103 addItemBool("LanguageChanged",&mLanguageChanged,false);
104 104
105 addItemBool("AskForQuit",&mAskForQuit,false); 105 addItemBool("AskForQuit",&mAskForQuit,false);
106 106
107#ifndef DESKTOP_VERSION 107#ifndef DESKTOP_VERSION
108 addItemBool("ShowFullMenu",&mShowFullMenu,false); 108 addItemBool("ShowFullMenu",&mShowFullMenu,false);
109#else 109#else
110 addItemBool("ShowFullMenu",&mShowFullMenu,true); 110 addItemBool("ShowFullMenu",&mShowFullMenu,true);
111#endif 111#endif
112 addItemBool("ToolBarHor",&mToolBarHor, true ); 112 addItemBool("ToolBarHor",&mToolBarHor, true );
113 addItemBool("ToolBarUp",&mToolBarUp, false ); 113 addItemBool("ToolBarUp",&mToolBarUp, false );
114 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 114 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
115 addItemInt("Whats Next Days",&mWhatsNextDays,3); 115 addItemInt("Whats Next Days",&mWhatsNextDays,3);
116 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 116 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
117 117
118 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 118 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
119 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 119 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
120 addItemInt("AllDay Size",&mAllDaySize,28); 120 addItemInt("AllDay Size",&mAllDaySize,28);
121 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 121 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
122 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 122 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
123 123
124 addItemStringList("LocationDefaults",&mLocationDefaults ); 124 addItemStringList("LocationDefaults",&mLocationDefaults );
125 addItemStringList("EventSummary User",&mEventSummaryUser); 125 addItemStringList("EventSummary User",&mEventSummaryUser);
126 addItemStringList("TodoSummary User",&mTodoSummaryUser); 126 addItemStringList("TodoSummary User",&mTodoSummaryUser);
127 127
128 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 128 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
129 addItemBool("Enable Project View",&mEnableProjectView,false); 129 addItemBool("Enable Project View",&mEnableProjectView,false);
130 addItemBool("Auto Save",&mAutoSave,false); 130 addItemBool("Auto Save",&mAutoSave,false);
131 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 131 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
132 addItemBool("Confirm Deletes",&mConfirm,true); 132 addItemBool("Confirm Deletes",&mConfirm,true);
133 addItemString("Archive File",&mArchiveFile); 133 addItemString("Archive File",&mArchiveFile);
134 addItemString("Html Export File",&mHtmlExportFile, 134 addItemString("Html Export File",&mHtmlExportFile,
135 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 135 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
136 addItemBool("Html With Save",&mHtmlWithSave,false); 136 addItemBool("Html With Save",&mHtmlWithSave,false);
137 137
138 KPrefs::setCurrentGroup("Personal Settings"); 138 KPrefs::setCurrentGroup("Personal Settings");
139 139
140 addItemInt("Mail Client",&mMailClient,MailClientKMail); 140 addItemInt("Mail Client",&mMailClient,MailClientKMail);
141 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 141 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
142 addItemBool("Bcc",&mBcc,false); 142 addItemBool("Bcc",&mBcc,false);
143 143
144 KPrefs::setCurrentGroup("Time & Date"); 144 KPrefs::setCurrentGroup("Time & Date");
145 145
146 // addItemString("Time Zone",&mTimeZone,"+0100"); 146 // addItemString("Time Zone",&mTimeZone,"+0100");
147 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 147 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
148 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); 148 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
149 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 149 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
150 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 150 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
151 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 151 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 addItemInt("Daylight Savings",&mDaylightSavings,0); 157 addItemInt("Daylight Savings",&mDaylightSavings,0);
158 KPrefs::setCurrentGroup("AlarmSettings"); 158 KPrefs::setCurrentGroup("AlarmSettings");
159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
163 163
164 164
165 KPrefs::setCurrentGroup("Calendar"); 165 KPrefs::setCurrentGroup("Calendar");
166 166
167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
168 168
169 KPrefs::setCurrentGroup("Fonts"); 169 KPrefs::setCurrentGroup("Fonts");
170 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 170 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
171 addItemFont("TimeBar Font",&mTimeBarFont); 171 addItemFont("TimeBar Font",&mTimeBarFont);
172 addItemFont("MonthView Font",&mMonthViewFont); 172 addItemFont("MonthView Font",&mMonthViewFont);
173 addItemFont("AgendaView Font",&mAgendaViewFont); 173 addItemFont("AgendaView Font",&mAgendaViewFont);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont);
176 addItemFont("TodoView Font",&mTodoViewFont); 176 addItemFont("TodoView Font",&mTodoViewFont);
177 addItemFont("ListView Font",&mListViewFont); 177 addItemFont("ListView Font",&mListViewFont);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont);
179 addItemFont("EditBox Font",&mEditBoxFont); 179 addItemFont("EditBox Font",&mEditBoxFont);
180 addItemFont("JournalView Font",&mJornalViewFont); 180 addItemFont("JournalView Font",&mJornalViewFont);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont);
182 addItemFont("EventView Font",&mEventViewFont); 182 addItemFont("EventView Font",&mEventViewFont);
183 183
184// KPrefs::setCurrentGroup("SyncProfiles"); 184// KPrefs::setCurrentGroup("SyncProfiles");
185// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 185// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
186// addItemStringList("SyncProfileNames",&mSyncProfileNames); 186// addItemStringList("SyncProfileNames",&mSyncProfileNames);
187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
188 188
189 KPrefs::setCurrentGroup("RemoteSyncing"); 189 KPrefs::setCurrentGroup("RemoteSyncing");
190// addItemBool("UsePasswd",&mUsePassWd,false); 190// addItemBool("UsePasswd",&mUsePassWd,false);
191// addItemBool("WriteBackFile",&mWriteBackFile,true); 191// addItemBool("WriteBackFile",&mWriteBackFile,true);
192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
193// addItemBool("AskForPreferences",&mAskForPreferences,true); 193// addItemBool("AskForPreferences",&mAskForPreferences,true);
194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
195 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
196 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
197 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
198 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
199 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
200 addItemInt("LastSyncTime",&mLastSyncTime,0); 198 addItemInt("LastSyncTime",&mLastSyncTime,0);
201 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 199 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
202 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 200 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
203 201
204#ifdef _WIN32_ 202#ifdef _WIN32_
205 QString hdp= locateLocal("data","korganizer")+"\\\\"; 203 QString hdp= locateLocal("data","korganizer")+"\\\\";
206#else 204#else
207 QString hdp= locateLocal("data","korganizer")+"/"; 205 QString hdp= locateLocal("data","korganizer")+"/";
208#endif 206#endif
209// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 207// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
210// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 208// addItemString("RemoteUser",&mRemoteUser, "zaurus");
211// addItemString("RemotePassWd",&mRemotePassWd, ""); 209// addItemString("RemotePassWd",&mRemotePassWd, "");
212// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 210// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
213// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 211// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
214 212
215 213
216 KPrefs::setCurrentGroup("LoadSaveFileNames"); 214 KPrefs::setCurrentGroup("LoadSaveFileNames");
217 215
218 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 216 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
219 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 217 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
220 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 218 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
221 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 219 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
222 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 220 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
223 221
224 222
225 KPrefs::setCurrentGroup("Locale"); 223 KPrefs::setCurrentGroup("Locale");
226 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 224 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
227 addItemInt("PreferredTime",&mPreferredTime,0); 225 addItemInt("PreferredTime",&mPreferredTime,0);
228 addItemInt("PreferredDate",&mPreferredDate,0); 226 addItemInt("PreferredDate",&mPreferredDate,0);
229 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 227 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
230 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 228 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
231 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 229 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
232 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 230 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
233 231
234 232
235 KPrefs::setCurrentGroup("Colors"); 233 KPrefs::setCurrentGroup("Colors");
236 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 234 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
237 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 235 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
238 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 236 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
239 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 237 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
240 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 238 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
241 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 239 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
242 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 240 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
243 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 241 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
244 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 242 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
245 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 243 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
246 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 244 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
247 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 245 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
248 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 246 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
249 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 247 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
250 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 248 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
251 addItemBool("UseAppColors",&mUseAppColors,false); 249 addItemBool("UseAppColors",&mUseAppColors,false);
252 250
253 251
254 252
255 KPrefs::setCurrentGroup("Views"); 253 KPrefs::setCurrentGroup("Views");
256 addItemInt("Hour Size",&mHourSize,8); 254 addItemInt("Hour Size",&mHourSize,8);
257 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 255 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
258 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 256 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
259 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 257 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
260 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 258 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
261 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 259 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
262 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 260 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
263 addItemBool("Enable ToolTips",&mEnableToolTips,false); 261 addItemBool("Enable ToolTips",&mEnableToolTips,false);
264 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 262 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
265 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 263 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
266 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 264 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
267 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 265 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
268 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 266 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
269 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 267 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
270 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 268 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
271 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 269 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
272 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 270 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
273 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 271 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
274 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 272 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
275 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 273 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
276 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 274 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
277 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 275 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
278 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 276 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
279 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 277 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
280 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 278 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
281 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 279 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
282#ifdef DESKTOP_VERSION 280#ifdef DESKTOP_VERSION
283 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 281 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
284#else 282#else
285 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 283 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
286#endif 284#endif
287 addItemInt("Day Begins",&mDayBegins,7); 285 addItemInt("Day Begins",&mDayBegins,7);
288 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 286 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
289 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 287 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
290 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 288 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
291 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 289 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
292 290
293 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 291 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
294 addItemBool("Full View Month",&mFullViewMonth,true); 292 addItemBool("Full View Month",&mFullViewMonth,true);
295 addItemBool("Full View Todo",&mFullViewTodo,true); 293 addItemBool("Full View Todo",&mFullViewTodo,true);
296 addItemBool("Quick Todo",&mEnableQuickTodo,false); 294 addItemBool("Quick Todo",&mEnableQuickTodo,false);
297 295
298 addItemInt("Next X Days",&mNextXDays,3); 296 addItemInt("Next X Days",&mNextXDays,3);
299 297
300 KPrefs::setCurrentGroup("Printer"); 298 KPrefs::setCurrentGroup("Printer");
301 299
302 KPrefs::setCurrentGroup("Layout"); 300 KPrefs::setCurrentGroup("Layout");
303 301
304 addItemBool("CompactDialogs",&mCompactDialogs,false); 302 addItemBool("CompactDialogs",&mCompactDialogs,false);
305 addItemBool("VerticalScreen",&mVerticalScreen,true); 303 addItemBool("VerticalScreen",&mVerticalScreen,true);
306 304
307 KPrefs::setCurrentGroup("KOrganizer Plugins"); 305 KPrefs::setCurrentGroup("KOrganizer Plugins");
308 306
309 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 307 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
310 308
311 KPrefs::setCurrentGroup("Group Scheduling"); 309 KPrefs::setCurrentGroup("Group Scheduling");
312 310
313 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 311 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
314 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 312 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
315 addItemStringList("AdditionalMails",&mAdditionalMails,""); 313 addItemStringList("AdditionalMails",&mAdditionalMails,"");
316 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 314 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
317 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 315 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
318 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 316 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
319 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 317 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
320 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 318 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
321 319
322 KPrefs::setCurrentGroup( "Editors" ); 320 KPrefs::setCurrentGroup( "Editors" );
323 321
324 addItemStringList( "EventTemplates", &mEventTemplates ); 322 addItemStringList( "EventTemplates", &mEventTemplates );
325 addItemStringList( "TodoTemplates", &mTodoTemplates ); 323 addItemStringList( "TodoTemplates", &mTodoTemplates );
326 324
327 addItemInt("DestinationPolicy",&mDestination,standardDestination); 325 addItemInt("DestinationPolicy",&mDestination,standardDestination);
328 326
329 327
330 328
331} 329}
332 330
333 331
334KOPrefs::~KOPrefs() 332KOPrefs::~KOPrefs()
335{ 333{
336 if (mInstance == this) 334 if (mInstance == this)
337 mInstance = insd.setObject(0); 335 mInstance = insd.setObject(0);
338 setLocaleDict( 0 ); 336 setLocaleDict( 0 );
339 if ( mLocaleDict ) 337 if ( mLocaleDict )
340 delete mLocaleDict; 338 delete mLocaleDict;
341 //qDebug("KOPrefs::~KOPrefs() "); 339 //qDebug("KOPrefs::~KOPrefs() ");
342} 340}
343 341
344 342
345KOPrefs *KOPrefs::instance() 343KOPrefs *KOPrefs::instance()
346{ 344{
347 if (!mInstance) { 345 if (!mInstance) {
348 mInstance = insd.setObject(new KOPrefs()); 346 mInstance = insd.setObject(new KOPrefs());
349 mInstance->readConfig(); 347 mInstance->readConfig();
350 } 348 }
351 349
352 return mInstance; 350 return mInstance;
353} 351}
354 352
355void KOPrefs::usrSetDefaults() 353void KOPrefs::usrSetDefaults()
356{ 354{
357 355
358} 356}
359 357
360void KOPrefs::fillMailDefaults() 358void KOPrefs::fillMailDefaults()
361{ 359{
362 if (mName.isEmpty()) mName = i18n("Anonymous"); 360 if (mName.isEmpty()) mName = i18n("Anonymous");
363 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 361 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
364} 362}
365 363
366void KOPrefs::setTimeZoneIdDefault() 364void KOPrefs::setTimeZoneIdDefault()
367{ 365{
368 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 366 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
369} 367}
370 368
371void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
372{ 370{
373 mCustomCategories.clear(); 371 mCustomCategories.clear();
374 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
375 373
376 QStringList::Iterator it; 374 QStringList::Iterator it;
377 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
378 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
379 } 377 }
380} 378}
381 379
382QStringList KOPrefs::getDefaultList() 380QStringList KOPrefs::getDefaultList()
383{ 381{
384 QStringList retval ; 382 QStringList retval ;
385 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 383 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
386 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 384 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
387 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 385 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
388 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 386 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..ff09e19 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -89,225 +89,224 @@ class KOPrefs : public KPimPrefs
89 int mAutoSaveInterval; 89 int mAutoSaveInterval;
90 bool mConfirm; 90 bool mConfirm;
91 91
92 bool mEnableGroupScheduling; 92 bool mEnableGroupScheduling;
93 bool mEnableProjectView; 93 bool mEnableProjectView;
94 94
95 int mDefaultFormat; 95 int mDefaultFormat;
96 int mMailClient; 96 int mMailClient;
97 97
98 QString mTimeZone; 98 QString mTimeZone;
99 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius 99 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
100 //int mTimeZoneOffset; // e.g. -240 min 100 //int mTimeZoneOffset; // e.g. -240 min
101 int mStartTime; 101 int mStartTime;
102 int mDefaultDuration; 102 int mDefaultDuration;
103 int mAlarmTime; 103 int mAlarmTime;
104 int mDaylightSavings; 104 int mDaylightSavings;
105 105
106 int mWorkingHoursStart; 106 int mWorkingHoursStart;
107 int mWorkingHoursEnd; 107 int mWorkingHoursEnd;
108 bool mExcludeHolidays; 108 bool mExcludeHolidays;
109 bool mExcludeSaturdays; 109 bool mExcludeSaturdays;
110 bool mMarcusBainsShowSeconds; 110 bool mMarcusBainsShowSeconds;
111 111
112 QFont mTimeBarFont; 112 QFont mTimeBarFont;
113 QFont mMonthViewFont; 113 QFont mMonthViewFont;
114 QFont mAgendaViewFont; 114 QFont mAgendaViewFont;
115 QFont mMarcusBainsFont; 115 QFont mMarcusBainsFont;
116 QFont mTimeLabelsFont; 116 QFont mTimeLabelsFont;
117 QFont mTodoViewFont; 117 QFont mTodoViewFont;
118 QFont mListViewFont; 118 QFont mListViewFont;
119 QFont mDateNavigatorFont; 119 QFont mDateNavigatorFont;
120 QFont mEditBoxFont; 120 QFont mEditBoxFont;
121 QFont mJornalViewFont; 121 QFont mJornalViewFont;
122 QFont mWhatsNextFont; 122 QFont mWhatsNextFont;
123 QFont mEventViewFont; 123 QFont mEventViewFont;
124 124
125 125
126 126
127 127
128 QColor mHolidayColor; 128 QColor mHolidayColor;
129 QColor mHighlightColor; 129 QColor mHighlightColor;
130 QColor mEventColor; 130 QColor mEventColor;
131 QColor mAgendaBgColor; 131 QColor mAgendaBgColor;
132 QColor mWorkingHoursColor; 132 QColor mWorkingHoursColor;
133 QColor mTodoDueTodayColor; 133 QColor mTodoDueTodayColor;
134 QColor mTodoOverdueColor; 134 QColor mTodoOverdueColor;
135 QColor mMonthViewEvenColor; 135 QColor mMonthViewEvenColor;
136 QColor mMonthViewOddColor; 136 QColor mMonthViewOddColor;
137 QColor mMonthViewHolidayColor; 137 QColor mMonthViewHolidayColor;
138 bool mMonthViewUsesDayColors; 138 bool mMonthViewUsesDayColors;
139 bool mMonthViewSatSunTog; 139 bool mMonthViewSatSunTog;
140 QColor mAppColor1; 140 QColor mAppColor1;
141 QColor mAppColor2; 141 QColor mAppColor2;
142 bool mUseAppColors; 142 bool mUseAppColors;
143 143
144 int mDayBegins; 144 int mDayBegins;
145 int mHourSize; 145 int mHourSize;
146 int mAllDaySize; 146 int mAllDaySize;
147 bool mShowFullMenu; 147 bool mShowFullMenu;
148 bool mDailyRecur; 148 bool mDailyRecur;
149 bool mWeeklyRecur; 149 bool mWeeklyRecur;
150 bool mMonthDailyRecur; 150 bool mMonthDailyRecur;
151 bool mMonthWeeklyRecur; 151 bool mMonthWeeklyRecur;
152 bool mMonthShowIcons; 152 bool mMonthShowIcons;
153 bool mMonthShowShort; 153 bool mMonthShowShort;
154 bool mEnableToolTips; 154 bool mEnableToolTips;
155 bool mEnableMonthScroll; 155 bool mEnableMonthScroll;
156 bool mFullViewMonth; 156 bool mFullViewMonth;
157 bool mMonthViewUsesCategoryColor; 157 bool mMonthViewUsesCategoryColor;
158 bool mFullViewTodo; 158 bool mFullViewTodo;
159 bool mShowCompletedTodo; 159 bool mShowCompletedTodo;
160 bool mMarcusBainsEnabled; 160 bool mMarcusBainsEnabled;
161 int mNextXDays; 161 int mNextXDays;
162 int mWhatsNextDays; 162 int mWhatsNextDays;
163 int mWhatsNextPrios; 163 int mWhatsNextPrios;
164 bool mEnableQuickTodo; 164 bool mEnableQuickTodo;
165 bool mLanguageChanged; 165 bool mLanguageChanged;
166 166
167 bool mCompactDialogs; 167 bool mCompactDialogs;
168 bool mVerticalScreen; 168 bool mVerticalScreen;
169 169
170 bool mShowIconNewTodo; 170 bool mShowIconNewTodo;
171 bool mShowIconNewEvent; 171 bool mShowIconNewEvent;
172 bool mShowIconSearch; 172 bool mShowIconSearch;
173 bool mShowIconList; 173 bool mShowIconList;
174 bool mShowIconDay1; 174 bool mShowIconDay1;
175 bool mShowIconDay5; 175 bool mShowIconDay5;
176 bool mShowIconDay7; 176 bool mShowIconDay7;
177 bool mShowIconMonth; 177 bool mShowIconMonth;
178 bool mShowIconTodoview; 178 bool mShowIconTodoview;
179 bool mShowIconBackFast; 179 bool mShowIconBackFast;
180 bool mShowIconBack; 180 bool mShowIconBack;
181 bool mShowIconToday; 181 bool mShowIconToday;
182 bool mShowIconForward; 182 bool mShowIconForward;
183 bool mShowIconForwardFast; 183 bool mShowIconForwardFast;
184 bool mShowIconWhatsThis; 184 bool mShowIconWhatsThis;
185 bool mShowIconNextDays; 185 bool mShowIconNextDays;
186 bool mShowIconNext; 186 bool mShowIconNext;
187 bool mShowIconJournal; 187 bool mShowIconJournal;
188 188
189 bool mShowIconStretch; 189 bool mShowIconStretch;
190 190
191 bool mToolBarHor; 191 bool mToolBarHor;
192 bool mToolBarUp; 192 bool mToolBarUp;
193 bool mToolBarMiniIcons; 193 bool mToolBarMiniIcons;
194 194
195 bool mAskForQuit; 195 bool mAskForQuit;
196 bool mUsePassWd; 196 bool mUsePassWd;
197 bool mWriteBackFile; 197 bool mWriteBackFile;
198 int mWriteBackInFuture; 198 int mWriteBackInFuture;
199 bool mAskForPreferences; 199 bool mAskForPreferences;
200 bool mShowSyncSummary; 200 bool mShowSyncSummary;
201 bool mShowSyncEvents; 201 bool mShowSyncEvents;
202 bool mShowTodoInAgenda; 202 bool mShowTodoInAgenda;
203 bool mWriteBackExistingOnly; 203 bool mWriteBackExistingOnly;
204 204
205 QString mRemoteIP; 205 QString mRemoteIP;
206 QString mRemoteUser; 206 QString mRemoteUser;
207 QString mRemotePassWd; 207 QString mRemotePassWd;
208 QString mRemoteFile; 208 QString mRemoteFile;
209 QString mLocalTempFile; 209 QString mLocalTempFile;
210 QString mPhoneDevice; 210 QString mPhoneDevice;
211 QString mPhoneConnection; 211 QString mPhoneConnection;
212 QString mPhoneModel; 212 QString mPhoneModel;
213 213
214 int mLastSyncTime; 214 int mLastSyncTime;
215 int mSyncAlgoPrefs; 215 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 216 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 217 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles; 218 QStringList mExternSyncProfiles;
219 QString mLocalMachineName; 219 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 220 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 221 QColor *categoryColor(QString cat);
222 222
223 QString mArchiveFile; 223 QString mArchiveFile;
224 QString mHtmlExportFile; 224 QString mHtmlExportFile;
225 bool mHtmlWithSave; 225 bool mHtmlWithSave;
226 226
227 QStringList mSelectedPlugins; 227 QStringList mSelectedPlugins;
228 228
229 QString mLastImportFile; 229 QString mLastImportFile;
230 QString mLastVcalFile; 230 QString mLastVcalFile;
231 QString mLastSaveFile; 231 QString mLastSaveFile;
232 QString mLastLoadFile; 232 QString mLastLoadFile;
233 QString mLastSyncedLocalFile; 233 QString mLastSyncedLocalFile;
234 234
235 235
236 QString mDefaultAlarmFile; 236 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 237 int mIMIPScheduler;
238 int mIMIPSend; 238 int mIMIPSend;
239 QStringList mAdditionalMails; 239 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 240 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 241 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 242 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 243 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 244 int mIMIPAutoFreeBusyReply;
245 245
246 QStringList mTodoTemplates; 246 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 247 QStringList mEventTemplates;
248 248
249 int mDestination; 249 int mDestination;
250 250
251 251
252 bool mEditOnDoubleClick; 252 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 253 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 254 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 255 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 256 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 257 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 258 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 259 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 260 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 261 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 262 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 263 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 264 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 265 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 266 bool mMonthViewUsesForegroundColor;
267 267
268 bool mHightlightDateTimeEdit; 268 bool mHightlightDateTimeEdit;
269 bool mShortDateInViewer; 269 bool mShortDateInViewer;
270 270
271 QStringList mLocationDefaults; 271 QStringList mLocationDefaults;
272 QStringList mEventSummaryUser; 272 QStringList mEventSummaryUser;
273 QStringList mTodoSummaryUser; 273 QStringList mTodoSummaryUser;
274 274
275 bool mUseInternalAlarmNotification; 275 bool mUseInternalAlarmNotification;
276 int mAlarmPlayBeeps; 276 int mAlarmPlayBeeps;
277 int mAlarmSuspendTime; 277 int mAlarmSuspendTime;
278 int mAlarmSuspendCount; 278 int mAlarmSuspendCount;
279 int mAlarmBeepInterval; 279 int mAlarmBeepInterval;
280 280
281 QString mPassiveSyncPort; 281
282 QString mPassiveSyncPw;
283 QString mActiveSyncPort; 282 QString mActiveSyncPort;
284 QString mActiveSyncIP; 283 QString mActiveSyncIP;
285 284
286 285
287 //US I copied the following settings into KPimGlobalPrefs 286 //US I copied the following settings into KPimGlobalPrefs
288 // that allows us later to easily remove the settings from here. 287 // that allows us later to easily remove the settings from here.
289 int mPreferredDate; 288 int mPreferredDate;
290 QString mUserDateFormatLong; 289 QString mUserDateFormatLong;
291 QString mUserDateFormatShort; 290 QString mUserDateFormatShort;
292 int mPreferredLanguage; 291 int mPreferredLanguage;
293 int mPreferredTime; 292 int mPreferredTime;
294 bool mWeekStartsOnSunday; 293 bool mWeekStartsOnSunday;
295 QString mTimeZoneId; 294 QString mTimeZoneId;
296 bool mUseDaylightsaving; 295 bool mUseDaylightsaving;
297 int mDaylightsavingStart; 296 int mDaylightsavingStart;
298 int mDaylightsavingEnd; 297 int mDaylightsavingEnd;
299 298
300 299
301 private: 300 private:
302 QDict<QColor> mCategoryColors; 301 QDict<QColor> mCategoryColors;
303 QColor mDefaultCategoryColor; 302 QColor mDefaultCategoryColor;
304 303
305 QFont mDefaultTimeBarFont; 304 QFont mDefaultTimeBarFont;
306 QFont mDefaultViewFont; 305 QFont mDefaultViewFont;
307 QFont mDefaultMonthViewFont; 306 QFont mDefaultMonthViewFont;
308 307
309 QString mName; 308 QString mName;
310 QString mEmail; 309 QString mEmail;
311}; 310};
312 311
313#endif 312#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9104347..e3324ee 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,325 +1,324 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 mPassWordPiSync = "abc"; 129 mPassWordPiSync = "abc";
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mSyncActionDialog = 0;
134 mServerSocket = 0; 133 mServerSocket = 0;
135 mClosed = false; 134 mClosed = false;
136 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
137 QString confFile = locateLocal("config","korganizerrc"); 136 QString confFile = locateLocal("config","korganizerrc");
138 QFileInfo finf ( confFile ); 137 QFileInfo finf ( confFile );
139 bool showWarning = !finf.exists(); 138 bool showWarning = !finf.exists();
140 setIcon(SmallIcon( "ko24" ) ); 139 setIcon(SmallIcon( "ko24" ) );
141 mBlockAtStartup = true; 140 mBlockAtStartup = true;
142 mFlagKeyPressed = false; 141 mFlagKeyPressed = false;
143 setCaption("KOrganizer/Pi"); 142 setCaption("KOrganizer/Pi");
144 KOPrefs *p = KOPrefs::instance(); 143 KOPrefs *p = KOPrefs::instance();
145 KPimGlobalPrefs::instance()->setGlobalConfig(); 144 KPimGlobalPrefs::instance()->setGlobalConfig();
146 // if ( QApplication::desktop()->height() > 480 ) { 145 // if ( QApplication::desktop()->height() > 480 ) {
147// if ( p->mHourSize == 4 ) 146// if ( p->mHourSize == 4 )
148// p->mHourSize = 6; 147// p->mHourSize = 6;
149// } 148// }
150 if ( p->mHourSize > 18 ) 149 if ( p->mHourSize > 18 )
151 p->mHourSize = 18; 150 p->mHourSize = 18;
152 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
153 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
154 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
155 tbd = Bottom; 154 tbd = Bottom;
156 else 155 else
157 tbd = Top; 156 tbd = Top;
158 } 157 }
159 else { 158 else {
160 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
161 tbd = Right; 160 tbd = Right;
162 else 161 else
163 tbd = Left; 162 tbd = Left;
164 } 163 }
165 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
166 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
167 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
168 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
169 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
170 mBlockSaveFlag = false; 169 mBlockSaveFlag = false;
171 mCalendarModifiedFlag = false; 170 mCalendarModifiedFlag = false;
172 171
173 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
174 splash->setAlignment ( AlignCenter ); 173 splash->setAlignment ( AlignCenter );
175 setCentralWidget( splash ); 174 setCentralWidget( splash );
176#ifndef DESKTOP_VERSION 175#ifndef DESKTOP_VERSION
177 showMaximized(); 176 showMaximized();
178#endif 177#endif
179 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 178 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
180 setDefaultPreferences(); 179 setDefaultPreferences();
181 mCalendar = new CalendarLocal(); 180 mCalendar = new CalendarLocal();
182 mView = new CalendarView( mCalendar, this,"mCalendar " ); 181 mView = new CalendarView( mCalendar, this,"mCalendar " );
183 mView->hide(); 182 mView->hide();
184 //mView->resize(splash->size() ); 183 //mView->resize(splash->size() );
185 initActions(); 184 initActions();
186#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
187 iconToolBar->show(); 186 iconToolBar->show();
188 qApp->processEvents(); 187 qApp->processEvents();
189#endif 188#endif
190 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
191 int vh = height() ; 190 int vh = height() ;
192 int vw = width(); 191 int vw = width();
193 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 192 //qDebug("Toolbar hei %d ",iconToolBar->height() );
194 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 193 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
195 vh -= iconToolBar->height(); 194 vh -= iconToolBar->height();
196 } else { 195 } else {
197 vw -= iconToolBar->height(); 196 vw -= iconToolBar->height();
198 } 197 }
199 //mView->setMaximumSize( splash->size() ); 198 //mView->setMaximumSize( splash->size() );
200 //mView->resize( splash->size() ); 199 //mView->resize( splash->size() );
201 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
202 mView->readSettings(); 201 mView->readSettings();
203 bool newFile = false; 202 bool newFile = false;
204 if( !QFile::exists( defaultFileName() ) ) { 203 if( !QFile::exists( defaultFileName() ) ) {
205 QFileInfo finfo ( defaultFileName() ); 204 QFileInfo finfo ( defaultFileName() );
206 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
207 qDebug("oldfile %s ", oldFile.latin1()); 206 qDebug("oldfile %s ", oldFile.latin1());
208 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
209 finfo.setFile( oldFile ); 208 finfo.setFile( oldFile );
210 if (finfo.exists() ) { 209 if (finfo.exists() ) {
211 KMessageBox::information( this, message); 210 KMessageBox::information( this, message);
212 mView->openCalendar( oldFile ); 211 mView->openCalendar( oldFile );
213 qApp->processEvents(); 212 qApp->processEvents();
214 } else { 213 } else {
215 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
216 finfo.setFile( oldFile ); 215 finfo.setFile( oldFile );
217 if (finfo.exists() ) { 216 if (finfo.exists() ) {
218 KMessageBox::information( this, message); 217 KMessageBox::information( this, message);
219 mView->openCalendar( oldFile ); 218 mView->openCalendar( oldFile );
220 qApp->processEvents(); 219 qApp->processEvents();
221 } 220 }
222 } 221 }
223 mView->saveCalendar( defaultFileName() ); 222 mView->saveCalendar( defaultFileName() );
224 newFile = true; 223 newFile = true;
225 } 224 }
226 225
227 QTime neededSaveTime = QDateTime::currentDateTime().time(); 226 QTime neededSaveTime = QDateTime::currentDateTime().time();
228 mView->openCalendar( defaultFileName() ); 227 mView->openCalendar( defaultFileName() );
229 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
230 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 229 qDebug("KO: Calendar loading time: %d ms",msNeeded );
231 230
232 if ( KOPrefs::instance()->mLanguageChanged ) { 231 if ( KOPrefs::instance()->mLanguageChanged ) {
233 KOPrefs::instance()->setCategoryDefaults(); 232 KOPrefs::instance()->setCategoryDefaults();
234 int count = mView->addCategories(); 233 int count = mView->addCategories();
235 KOPrefs::instance()->mLanguageChanged = false; 234 KOPrefs::instance()->mLanguageChanged = false;
236 } 235 }
237 processIncidenceSelection( 0 ); 236 processIncidenceSelection( 0 );
238 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 237 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
239 SLOT( processIncidenceSelection( Incidence * ) ) ); 238 SLOT( processIncidenceSelection( Incidence * ) ) );
240 connect( mView, SIGNAL( modifiedChanged( bool ) ), 239 connect( mView, SIGNAL( modifiedChanged( bool ) ),
241 SLOT( slotModifiedChanged( bool ) ) ); 240 SLOT( slotModifiedChanged( bool ) ) );
242 241
243 242
244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 243 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
245 mView->setModified( false ); 244 mView->setModified( false );
246 mBlockAtStartup = false; 245 mBlockAtStartup = false;
247 mView->setModified( false ); 246 mView->setModified( false );
248 setCentralWidget( mView ); 247 setCentralWidget( mView );
249 globalFlagBlockStartup = 0; 248 globalFlagBlockStartup = 0;
250 mView->show(); 249 mView->show();
251 delete splash; 250 delete splash;
252 if ( newFile ) 251 if ( newFile )
253 mView->updateConfig(); 252 mView->updateConfig();
254 // qApp->processEvents(); 253 // qApp->processEvents();
255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 254 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
256 fillSyncMenu(); 255 fillSyncMenu();
257 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 256 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
258 if ( showWarning ) { 257 if ( showWarning ) {
259 KMessageBox::information( this, 258 KMessageBox::information( this,
260 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 259 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
261 qApp->processEvents(); 260 qApp->processEvents();
262 mView->dialogManager()->showSyncOptions(); 261 mView->dialogManager()->showSyncOptions();
263 } 262 }
264 263
265 //US listen for result adressed from Ka/Pi 264 //US listen for result adressed from Ka/Pi
266#ifndef DESKTOP_VERSION 265#ifndef DESKTOP_VERSION
267 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 266 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
268#endif 267#endif
269} 268}
270MainWindow::~MainWindow() 269MainWindow::~MainWindow()
271{ 270{
272 //qDebug("MainWindow::~MainWindow() "); 271 //qDebug("MainWindow::~MainWindow() ");
273 //save toolbar location 272 //save toolbar location
274 delete mServerSocket; 273 delete mServerSocket;
275 delete mCalendar; 274 delete mCalendar;
276 delete KOPrefs::instance(); 275 delete KOPrefs::instance();
277 delete KIncidenceFormatter::instance(); 276 delete KIncidenceFormatter::instance();
278 277
279 278
280} 279}
281void MainWindow::showMaximized () 280void MainWindow::showMaximized ()
282{ 281{
283#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
284 if ( ! globalFlagBlockStartup ) 283 if ( ! globalFlagBlockStartup )
285 if ( mClosed ) 284 if ( mClosed )
286 mView->goToday(); 285 mView->goToday();
287#endif 286#endif
288 QWidget::showMaximized () ; 287 QWidget::showMaximized () ;
289 mClosed = false; 288 mClosed = false;
290} 289}
291void MainWindow::closeEvent( QCloseEvent* ce ) 290void MainWindow::closeEvent( QCloseEvent* ce )
292{ 291{
293 292
294 293
295 294
296 if ( ! KOPrefs::instance()->mAskForQuit ) { 295 if ( ! KOPrefs::instance()->mAskForQuit ) {
297 saveOnClose(); 296 saveOnClose();
298 mClosed = true; 297 mClosed = true;
299 ce->accept(); 298 ce->accept();
300 return; 299 return;
301 300
302 } 301 }
303 302
304 switch( QMessageBox::information( this, "KO/Pi", 303 switch( QMessageBox::information( this, "KO/Pi",
305 i18n("Do you really want\nto close KO/Pi?"), 304 i18n("Do you really want\nto close KO/Pi?"),
306 i18n("Close"), i18n("No"), 305 i18n("Close"), i18n("No"),
307 0, 0 ) ) { 306 0, 0 ) ) {
308 case 0: 307 case 0:
309 saveOnClose(); 308 saveOnClose();
310 mClosed = true; 309 mClosed = true;
311 ce->accept(); 310 ce->accept();
312 break; 311 break;
313 case 1: 312 case 1:
314 ce->ignore(); 313 ce->ignore();
315 break; 314 break;
316 case 2: 315 case 2:
317 316
318 default: 317 default:
319 break; 318 break;
320 } 319 }
321 320
322 321
323} 322}
324 323
325void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 324void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
@@ -2158,512 +2157,192 @@ void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
2158 delete s; 2157 delete s;
2159} 2158}
2160 2159
2161void MainWindow::readFileFromSocket() 2160void MainWindow::readFileFromSocket()
2162{ 2161{
2163 QString fileName = syncFileName(); 2162 QString fileName = syncFileName();
2164 setCaption( i18n("Remote file saved to temp file.") ); 2163 setCaption( i18n("Remote file saved to temp file.") );
2165 if ( ! syncWithFile( fileName , true ) ) { 2164 if ( ! syncWithFile( fileName , true ) ) {
2166 setCaption( i18n("Syncing failed.") ); 2165 setCaption( i18n("Syncing failed.") );
2167 qDebug("Syncing failed "); 2166 qDebug("Syncing failed ");
2168 return; 2167 return;
2169 } 2168 }
2170 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2169 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2171 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2170 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2172 if ( KOPrefs::instance()->mWriteBackFile ) 2171 if ( KOPrefs::instance()->mWriteBackFile )
2173 commandSocket->writeFile( fileName ); 2172 commandSocket->writeFile( fileName );
2174 else { 2173 else {
2175 commandSocket->sendStop(); 2174 commandSocket->sendStop();
2176 setCaption( i18n("Pi-Sync succesful!") ); 2175 setCaption( i18n("Pi-Sync succesful!") );
2177 } 2176 }
2178} 2177}
2179 2178
2180void MainWindow::syncLocalFile() 2179void MainWindow::syncLocalFile()
2181{ 2180{
2182 2181
2183 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2182 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2184 2183
2185 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2184 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2186 if ( fn == "" ) 2185 if ( fn == "" )
2187 return; 2186 return;
2188 //mView->setSyncDevice("local-file" ); 2187 //mView->setSyncDevice("local-file" );
2189 if ( syncWithFile( fn, false ) ) { 2188 if ( syncWithFile( fn, false ) ) {
2190 // Event* e = mView->getLastSyncEvent(); 2189 // Event* e = mView->getLastSyncEvent();
2191// e->setReadOnly( false ); 2190// e->setReadOnly( false );
2192// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2191// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2193// e->setReadOnly( true ); 2192// e->setReadOnly( true );
2194 } 2193 }
2195 2194
2196} 2195}
2197 2196
2198bool MainWindow::syncWithFile( QString fn , bool quick ) 2197bool MainWindow::syncWithFile( QString fn , bool quick )
2199{ 2198{
2200 bool ret = false; 2199 bool ret = false;
2201 QFileInfo info; 2200 QFileInfo info;
2202 info.setFile( fn ); 2201 info.setFile( fn );
2203 QString mess; 2202 QString mess;
2204 bool loadbup = true; 2203 bool loadbup = true;
2205 if ( !info. exists() ) { 2204 if ( !info. exists() ) {
2206 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2205 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2207 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2206 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2208 mess ); 2207 mess );
2209 return ret; 2208 return ret;
2210 } 2209 }
2211 int result = 0; 2210 int result = 0;
2212 if ( !quick ) { 2211 if ( !quick ) {
2213 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2212 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2214 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2213 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2215 mess, 2214 mess,
2216 i18n("Sync"), i18n("Cancel"), 0, 2215 i18n("Sync"), i18n("Cancel"), 0,
2217 0, 1 ); 2216 0, 1 );
2218 if ( result ) 2217 if ( result )
2219 return false; 2218 return false;
2220 } 2219 }
2221 if ( KOPrefs::instance()->mAskForPreferences ) 2220 if ( KOPrefs::instance()->mAskForPreferences )
2222 mView->edit_sync_options(); 2221 mView->edit_sync_options();
2223 if ( result == 0 ) { 2222 if ( result == 0 ) {
2224 //qDebug("Now sycing ... "); 2223 //qDebug("Now sycing ... ");
2225 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2224 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2226 setCaption( i18n("Synchronization successful") ); 2225 setCaption( i18n("Synchronization successful") );
2227 else 2226 else
2228 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2227 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2229 if ( ! quick ) 2228 if ( ! quick )
2230 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2229 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2231 slotModifiedChanged( true ); 2230 slotModifiedChanged( true );
2232 } 2231 }
2233 return ret; 2232 return ret;
2234} 2233}
2235void MainWindow::quickSyncLocalFile() 2234void MainWindow::quickSyncLocalFile()
2236{ 2235{
2237 //mView->setSyncDevice("local-file" ); 2236 //mView->setSyncDevice("local-file" );
2238 //qDebug("quickSyncLocalFile() "); 2237 //qDebug("quickSyncLocalFile() ");
2239 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2238 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2240 // Event* e = mView->getLastSyncEvent(); 2239 // Event* e = mView->getLastSyncEvent();
2241// e->setReadOnly( false ); 2240// e->setReadOnly( false );
2242// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2241// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2243// e->setReadOnly( true ); 2242// e->setReadOnly( true );
2244 2243
2245 } 2244 }
2246} 2245}
2247 2246
2248void MainWindow::confSync() 2247void MainWindow::confSync()
2249{ 2248{
2250 mView->confSync(); 2249 mView->confSync();
2251 fillSyncMenu(); 2250 fillSyncMenu();
2252} 2251}
2253void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2252void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2254{ 2253{
2255 QString question; 2254 QString question;
2256 if ( ask ) { 2255 if ( ask ) {
2257 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2256 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2258 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2257 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2259 question, 2258 question,
2260 i18n("Yes"), i18n("No"), 2259 i18n("Yes"), i18n("No"),
2261 0, 0 ) != 0 ) 2260 0, 0 ) != 0 )
2262 return; 2261 return;
2263 } 2262 }
2264 QString command = prof->getPreSyncCommand(); 2263 QString command = prof->getPreSyncCommand();
2265 int fi; 2264 int fi;
2266 if ( (fi = command.find("$PWD$")) > 0 ) { 2265 if ( (fi = command.find("$PWD$")) > 0 ) {
2267 QString pwd = getPassword(); 2266 QString pwd = getPassword();
2268 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2267 command = command.left( fi )+ pwd + command.mid( fi+5 );
2269 2268
2270 } 2269 }
2271 int maxlen = 30; 2270 int maxlen = 30;
2272 if ( QApplication::desktop()->width() > 320 ) 2271 if ( QApplication::desktop()->width() > 320 )
2273 maxlen += 25; 2272 maxlen += 25;
2274 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2273 setCaption ( i18n( "Copy remote file to local machine..." ) );
2275 int fileSize = 0; 2274 int fileSize = 0;
2276 int result = system ( command ); 2275 int result = system ( command );
2277 // 0 : okay 2276 // 0 : okay
2278 // 256: no such file or dir 2277 // 256: no such file or dir
2279 // 2278 //
2280 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2279 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2281 if ( result != 0 ) { 2280 if ( result != 0 ) {
2282 int len = maxlen; 2281 int len = maxlen;
2283 while ( len < command.length() ) { 2282 while ( len < command.length() ) {
2284 command.insert( len , "\n" ); 2283 command.insert( len , "\n" );
2285 len += maxlen +2; 2284 len += maxlen +2;
2286 } 2285 }
2287 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2286 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2288 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2287 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2289 question, 2288 question,
2290 i18n("Okay!")) ; 2289 i18n("Okay!")) ;
2291 setCaption ("KO/Pi"); 2290 setCaption ("KO/Pi");
2292 return; 2291 return;
2293 } 2292 }
2294 setCaption ( i18n( "Copying succeed." ) ); 2293 setCaption ( i18n( "Copying succeed." ) );
2295 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2294 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2296 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2295 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2297// Event* e = mView->getLastSyncEvent(); 2296// Event* e = mView->getLastSyncEvent();
2298// e->setReadOnly( false ); 2297// e->setReadOnly( false );
2299// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2298// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2300// e->setReadOnly( true ); 2299// e->setReadOnly( true );
2301 if ( KOPrefs::instance()->mWriteBackFile ) { 2300 if ( KOPrefs::instance()->mWriteBackFile ) {
2302 command = prof->getPostSyncCommand(); 2301 command = prof->getPostSyncCommand();
2303 int fi; 2302 int fi;
2304 if ( (fi = command.find("$PWD$")) > 0 ) { 2303 if ( (fi = command.find("$PWD$")) > 0 ) {
2305 QString pwd = getPassword(); 2304 QString pwd = getPassword();
2306 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2305 command = command.left( fi )+ pwd + command.mid( fi+5 );
2307 2306
2308 } 2307 }
2309 setCaption ( i18n( "Writing back file ..." ) ); 2308 setCaption ( i18n( "Writing back file ..." ) );
2310 result = system ( command ); 2309 result = system ( command );
2311 qDebug("KO: Writing back file result: %d ", result); 2310 qDebug("KO: Writing back file result: %d ", result);
2312 if ( result != 0 ) { 2311 if ( result != 0 ) {
2313 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2312 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2314 return; 2313 return;
2315 } else { 2314 } else {
2316 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2315 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2317 } 2316 }
2318 } 2317 }
2319 } 2318 }
2320 return; 2319 return;
2321} 2320}
2322 2321
2323void MainWindow::syncSharp() 2322void MainWindow::syncSharp()
2324{ 2323{
2325 if ( mCalendarModifiedFlag ) 2324 if ( mCalendarModifiedFlag )
2326 save(); 2325 save();
2327 mView->syncSharp(); 2326 mView->syncSharp();
2328 slotModifiedChanged( true ); 2327 slotModifiedChanged( true );
2329 2328
2330} 2329}
2331void MainWindow::syncPhone() 2330void MainWindow::syncPhone()
2332{ 2331{
2333 if ( mCalendarModifiedFlag ) 2332 if ( mCalendarModifiedFlag )
2334 save(); 2333 save();
2335 mView->syncPhone(); 2334 mView->syncPhone();
2336 slotModifiedChanged( true ); 2335 slotModifiedChanged( true );
2337 2336
2338} 2337}
2339 2338
2340void MainWindow::printSel( ) 2339void MainWindow::printSel( )
2341{ 2340{
2342 mView->viewManager()->agendaView()->agenda()->printSelection(); 2341 mView->viewManager()->agendaView()->agenda()->printSelection();
2343} 2342}
2344 2343
2345void MainWindow::printCal() 2344void MainWindow::printCal()
2346{ 2345{
2347 mView->print();//mCp->showDialog(); 2346 mView->print();//mCp->showDialog();
2348} 2347}
2349 2348
2350
2351
2352KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2353{
2354 mPassWord = pw;
2355 mSocket = 0;
2356 mSyncActionDialog = 0;
2357 blockRC = false;
2358};
2359
2360void KServerSocket::newConnection ( int socket )
2361{
2362 // qDebug("KServerSocket:New connection %d ", socket);
2363 if ( mSocket ) {
2364 qDebug("KServerSocket::newConnection Socket deleted! ");
2365 delete mSocket;
2366 mSocket = 0;
2367 }
2368 mSocket = new QSocket( this );
2369 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2370 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2371 mSocket->setSocket( socket );
2372}
2373
2374void KServerSocket::discardClient()
2375{
2376 //qDebug(" KServerSocket::discardClient()");
2377 if ( mSocket ) {
2378 delete mSocket;
2379 mSocket = 0;
2380 }
2381 //emit endConnect();
2382}
2383void KServerSocket::readClient()
2384{
2385 if ( blockRC )
2386 return;
2387 if ( mSocket == 0 ) {
2388 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2389 return;
2390 }
2391 qDebug("KServerSocket readClient()");
2392 if ( mSocket->canReadLine() ) {
2393 QString line = mSocket->readLine();
2394 qDebug("KServerSocket readline: %s ", line.latin1());
2395 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
2396 if ( tokens[0] == "GET" ) {
2397 if ( tokens[1] == mPassWord )
2398 //emit sendFile( mSocket );
2399 send_file();
2400 else {
2401 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2402 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2403 }
2404 }
2405 if ( tokens[0] == "PUT" ) {
2406 if ( tokens[1] == mPassWord ) {
2407 //emit getFile( mSocket );
2408 blockRC = true;
2409 get_file();
2410 }
2411 else {
2412 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2413 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2414 }
2415 }
2416 if ( tokens[0] == "STOP" ) {
2417 //emit endConnect();
2418 end_connect();
2419 }
2420 }
2421}
2422void KServerSocket::end_connect()
2423{
2424 delete mSyncActionDialog;
2425 mSyncActionDialog = 0;
2426}
2427void KServerSocket::send_file()
2428{
2429 //qDebug("MainWindow::sendFile(QSocket* s) ");
2430 if ( mSyncActionDialog )
2431 delete mSyncActionDialog;
2432 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2433 mSyncActionDialog->setCaption(i18n("Received sync request"));
2434 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
2435 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2436 lay->addWidget( label);
2437 lay->setMargin(7);
2438 lay->setSpacing(7);
2439 mSyncActionDialog->setFixedSize( 230, 120);
2440 mSyncActionDialog->show();
2441 qDebug("KSS::saving ... ");
2442 emit saveFile();
2443 qApp->processEvents();
2444 QString fileName = mFileName;
2445 QFile file( fileName );
2446 if (!file.open( IO_ReadOnly ) ) {
2447 delete mSyncActionDialog;
2448 mSyncActionDialog = 0;
2449 qDebug("KSS::error open file ");
2450 mSocket->close();
2451 if ( mSocket->state() == QSocket::Idle )
2452 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2453 return ;
2454
2455 }
2456 mSyncActionDialog->setCaption( i18n("Sending file...") );
2457 QTextStream ts( &file );
2458 ts.setCodec( QTextCodec::codecForName("utf8") );
2459 QTextStream os( mSocket );
2460 os.setCodec( QTextCodec::codecForName("utf8") );
2461 //os.setEncoding( QTextStream::UnicodeUTF8 );
2462 while ( ! ts.atEnd() ) {
2463 os << ts.readLine() << "\n";
2464 }
2465 //os << ts.read();
2466 file.close();
2467 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
2468 mSocket->close();
2469 if ( mSocket->state() == QSocket::Idle )
2470 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2471}
2472void KServerSocket::get_file()
2473{
2474 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2475
2476 piTime.start();
2477 piFileString = "";
2478 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2479}
2480
2481
2482void KServerSocket::readBackFileFromSocket()
2483{
2484 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2485 while ( mSocket->canReadLine () ) {
2486 piTime.restart();
2487 QString line = mSocket->readLine ();
2488 piFileString += line;
2489 //qDebug("readline: %s ", line.latin1());
2490 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2491
2492 }
2493 if ( piTime.elapsed () < 3000 ) {
2494 // wait for more
2495 //qDebug("waitformore ");
2496 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2497 return;
2498 }
2499 QString fileName = mFileName;
2500 QFile file ( fileName );
2501 if (!file.open( IO_WriteOnly ) ) {
2502 delete mSyncActionDialog;
2503 mSyncActionDialog = 0;
2504 qDebug("error open cal file ");
2505 piFileString = "";
2506 emit file_received( false );
2507 blockRC = false;
2508 return ;
2509
2510 }
2511
2512 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2513 QTextStream ts ( &file );
2514 ts.setCodec( QTextCodec::codecForName("utf8") );
2515 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2516 ts << piFileString;
2517 mSocket->close();
2518 if ( mSocket->state() == QSocket::Idle )
2519 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2520 file.close();
2521 delete mSyncActionDialog;
2522 mSyncActionDialog = 0;
2523 piFileString = "";
2524 blockRC = false;
2525 emit file_received( true );
2526
2527}
2528
2529KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2530{
2531 mPassWord = password;
2532 mSocket = 0;
2533 mPort = port;
2534 mHost = host;
2535
2536 mRetVal = quiet;
2537 mTimerSocket = new QTimer ( this );
2538 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2539}
2540void KCommandSocket::readFile( QString fn )
2541{
2542 if ( !mSocket ) {
2543 mSocket = new QSocket( this );
2544 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2545 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2546 }
2547 mFileString = "";
2548 mFileName = fn;
2549 mFirst = true;
2550 mSocket->connectToHost( mHost, mPort );
2551 QTextStream os( mSocket );
2552 os.setEncoding( QTextStream::UnicodeUTF8 );
2553 os << "GET " << mPassWord << "\r\n";
2554 mTimerSocket->start( 10000 );
2555}
2556
2557void KCommandSocket::writeFile( QString fileName )
2558{
2559 if ( !mSocket ) {
2560 mSocket = new QSocket( this );
2561 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2562 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
2563 }
2564 mFileName = fileName ;
2565 mSocket->connectToHost( mHost, mPort );
2566}
2567void KCommandSocket::writeFileToSocket()
2568{
2569 QFile file2( mFileName );
2570 if (!file2.open( IO_ReadOnly ) ) {
2571 mRetVal= errorW;
2572 mSocket->close();
2573 if ( mSocket->state() == QSocket::Idle )
2574 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2575 return ;
2576 }
2577 QTextStream ts2( &file2 );
2578 ts2.setCodec( QTextCodec::codecForName("utf8") );
2579 QTextStream os2( mSocket );
2580 os2.setCodec( QTextCodec::codecForName("utf8") );
2581 os2 << "PUT " << mPassWord << "\r\n";;
2582 while ( ! ts2.atEnd() ) {
2583 os2 << ts2.readLine() << "\n";
2584 }
2585 mRetVal= successW;
2586 file2.close();
2587 mSocket->close();
2588 if ( mSocket->state() == QSocket::Idle )
2589 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2590}
2591void KCommandSocket::sendStop()
2592{
2593 if ( !mSocket ) {
2594 mSocket = new QSocket( this );
2595 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2596 }
2597 mSocket->connectToHost( mHost, mPort );
2598 QTextStream os2( mSocket );
2599 os2.setCodec( QTextCodec::codecForName("utf8") );
2600 os2 << "STOP\r\n";
2601 mSocket->close();
2602 if ( mSocket->state() == QSocket::Idle )
2603 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2604}
2605
2606void KCommandSocket::startReadFileFromSocket()
2607{
2608 if ( ! mFirst )
2609 return;
2610 mFirst = false;
2611 mTimerSocket->stop();
2612 mFileString = "";
2613 mTime.start();
2614 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
2615
2616}
2617void KCommandSocket::readFileFromSocket()
2618{
2619 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
2620 while ( mSocket->canReadLine () ) {
2621 mTime.restart();
2622 QString line = mSocket->readLine ();
2623 mFileString += line;
2624 //qDebug("readline: %s ", line.latin1());
2625 }
2626 if ( mTime.elapsed () < 3000 ) {
2627 // wait for more
2628 //qDebug("waitformore ");
2629 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
2630 return;
2631 }
2632 QString fileName = mFileName;
2633 QFile file ( fileName );
2634 if (!file.open( IO_WriteOnly ) ) {
2635 mFileString = "";
2636 mRetVal = errorR;
2637 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2638 deleteSocket();
2639 return ;
2640
2641 }
2642 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2643 QTextStream ts ( &file );
2644 ts.setCodec( QTextCodec::codecForName("utf8") );
2645 ts << mFileString;
2646 file.close();
2647 mFileString = "";
2648 mRetVal = successR;
2649 mSocket->close();
2650 // if state is not idle, deleteSocket(); is called via
2651 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2652 if ( mSocket->state() == QSocket::Idle )
2653 deleteSocket();
2654}
2655
2656void KCommandSocket::deleteSocket()
2657{
2658 if ( mTimerSocket->isActive () ) {
2659 mTimerSocket->stop();
2660 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2661 mRetVal = errorR;
2662 }
2663 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
2664 if ( mSocket)
2665 delete mSocket;
2666 mSocket = 0;
2667 emit commandFinished( this, mRetVal );
2668}
2669
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 4f89e03..0da0be0 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,216 +1,148 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qsocket.h>
9#include <qtextstream.h> 8#include <qtextstream.h>
10#include <qregexp.h> 9#include <qregexp.h>
11 10
12#include <libkcal/incidence.h> 11#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 12#include "simplealarmclient.h"
13#include <ksyncmanager.h>
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24#include <qserversocket.h>
25#include <qsocket.h>
26#include <qnetworkprotocol.h>
27 24
28class KServerSocket : public QServerSocket
29{
30 Q_OBJECT
31
32public:
33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
34
35 void newConnection ( int socket ) ;
36 void setFileName( QString fn ) {mFileName = fn;};
37
38signals:
39 //void sendFile(QSocket*);
40 //void getFile(QSocket*);
41 void file_received( bool );
42 //void file_sent();
43 void saveFile();
44 void endConnect();
45private slots:
46 void discardClient();
47 void readClient();
48 void readBackFileFromSocket();
49 private :
50 bool blockRC;
51 void send_file();
52 void get_file();
53 void end_connect();
54 QDialog* mSyncActionDialog;
55 QSocket* mSocket;
56 QString mPassWord;
57 QString mFileName;
58 QTime piTime;
59 QString piFileString;
60};
61
62class KCommandSocket : public QObject
63{
64 Q_OBJECT
65public:
66 enum state { successR, errorR, successW, errorW, quiet };
67 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
68 void readFile( QString );
69 void writeFile( QString );
70 void sendStop();
71
72
73signals:
74 void commandFinished( KCommandSocket*, int );
75private slots:
76 void startReadFileFromSocket();
77 void readFileFromSocket();
78 void deleteSocket();
79 void writeFileToSocket();
80 private :
81 QSocket* mSocket;
82 QString mPassWord;
83 Q_UINT16 mPort;
84 QString mHost;
85 QString mFileName;
86 QTimer* mTimerSocket;
87 int mRetVal;
88 QTime mTime;
89 QString mFileString;
90 bool mFirst;
91};
92 25
93namespace KCal { 26namespace KCal {
94class CalendarLocal; 27class CalendarLocal;
95} 28}
96 29
97using namespace KCal; 30using namespace KCal;
98 31
99class MainWindow : public QMainWindow 32class MainWindow : public QMainWindow
100{ 33{
101 Q_OBJECT 34 Q_OBJECT
102 public: 35 public:
103 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 36 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
104 ~MainWindow(); 37 ~MainWindow();
105 public slots: 38 public slots:
106 virtual void showMaximized (); 39 virtual void showMaximized ();
107 void configureAgenda( int ); 40 void configureAgenda( int );
108 void recieve( const QCString& msg, const QByteArray& data ); 41 void recieve( const QCString& msg, const QByteArray& data );
109 static QString defaultFileName(); 42 static QString defaultFileName();
110 static QString syncFileName(); 43 static QString syncFileName();
111 static QString resourcePath(); 44 static QString resourcePath();
112 protected slots: 45 protected slots:
113 void setCaptionToDates(); 46 void setCaptionToDates();
114 int ringSync(); 47 int ringSync();
115 void multiSync( bool askforPrefs = false ); 48 void multiSync( bool askforPrefs = false );
116 void about(); 49 void about();
117 void licence(); 50 void licence();
118 void faq(); 51 void faq();
119 void usertrans(); 52 void usertrans();
120 void features(); 53 void features();
121 void synchowto(); 54 void synchowto();
122 void whatsNew(); 55 void whatsNew();
123 void keyBindings(); 56 void keyBindings();
124 void aboutAutoSaving();; 57 void aboutAutoSaving();;
125 void aboutKnownBugs(); 58 void aboutKnownBugs();
126 59
127 void processIncidenceSelection( Incidence * ); 60 void processIncidenceSelection( Incidence * );
128 61
129 void importQtopia(); 62 void importQtopia();
130 void importBday(); 63 void importBday();
131 void importOL(); 64 void importOL();
132 void importIcal(); 65 void importIcal();
133 void importFile( QString, bool ); 66 void importFile( QString, bool );
134 void quickImportIcal(); 67 void quickImportIcal();
135 68
136 void slotModifiedChanged( bool ); 69 void slotModifiedChanged( bool );
137 70
138 void save(); 71 void save();
139 void configureToolBar( int ); 72 void configureToolBar( int );
140 void printSel(); 73 void printSel();
141 void printCal(); 74 void printCal();
142 void saveCalendar(); 75 void saveCalendar();
143 void loadCalendar(); 76 void loadCalendar();
144 void exportVCalendar(); 77 void exportVCalendar();
145 void fillFilterMenu(); 78 void fillFilterMenu();
146 void selectFilter( int ); 79 void selectFilter( int );
147 void exportToPhone( int ); 80 void exportToPhone( int );
148 81
149 void slotSyncMenu( int ); 82 void slotSyncMenu( int );
150 void confSync(); 83 void confSync();
151 void syncSharp(); 84 void syncSharp();
152 void syncPhone(); 85 void syncPhone();
153 void syncPi(); 86 void syncPi();
154 void syncLocalFile(); 87 void syncLocalFile();
155 bool syncWithFile( QString, bool ); 88 bool syncWithFile( QString, bool );
156 void quickSyncLocalFile(); 89 void quickSyncLocalFile();
157 90
158 91
159 protected: 92 protected:
160 void displayText( QString, QString); 93 void displayText( QString, QString);
161 void displayFile( QString, QString); 94 void displayFile( QString, QString);
162 95
163 void enableIncidenceActions( bool ); 96 void enableIncidenceActions( bool );
164 97
165 private slots: 98 private slots:
166 QSocket* piSocket; 99 QSocket* piSocket;
167 QString piFileString; 100 QString piFileString;
168 QTime piTime; 101 QTime piTime;
169 void deleteCommandSocket(KCommandSocket* s, int state ); 102 void deleteCommandSocket(KCommandSocket* s, int state );
170 void fillSyncMenu(); 103 void fillSyncMenu();
171 void getFile( bool ); 104 void getFile( bool );
172 void readFileFromSocket(); 105 void readFileFromSocket();
173 private: 106 private:
174 //QTimer* mTimerCommandSocket; 107 //QTimer* mTimerCommandSocket;
175 QString mPassWordPiSync; 108 QString mPassWordPiSync;
176 KServerSocket * mServerSocket; 109 KServerSocket * mServerSocket;
177 bool mClosed; 110 bool mClosed;
178 void saveOnClose(); 111 void saveOnClose();
179 int mCurrentSyncProfile; 112 int mCurrentSyncProfile;
180 void enableQuick(); 113 void enableQuick();
181 void syncRemote( KSyncProfile* , bool ask = true); 114 void syncRemote( KSyncProfile* , bool ask = true);
182 bool mFlagKeyPressed; 115 bool mFlagKeyPressed;
183 bool mBlockAtStartup; 116 bool mBlockAtStartup;
184 QPEToolBar *iconToolBar; 117 QPEToolBar *iconToolBar;
185 void initActions(); 118 void initActions();
186 void setDefaultPreferences(); 119 void setDefaultPreferences();
187 void keyPressEvent ( QKeyEvent * ) ; 120 void keyPressEvent ( QKeyEvent * ) ;
188 void keyReleaseEvent ( QKeyEvent * ) ; 121 void keyReleaseEvent ( QKeyEvent * ) ;
189 QPopupMenu *configureToolBarMenu; 122 QPopupMenu *configureToolBarMenu;
190 QPopupMenu *selectFilterMenu; 123 QPopupMenu *selectFilterMenu;
191 QPopupMenu *configureAgendaMenu, *syncMenu; 124 QPopupMenu *configureAgendaMenu, *syncMenu;
192 CalendarLocal *mCalendar; 125 CalendarLocal *mCalendar;
193 CalendarView *mView; 126 CalendarView *mView;
194 QString getPassword(); 127 QString getPassword();
195 QAction *mNewSubTodoAction; 128 QAction *mNewSubTodoAction;
196 129
197 QAction *mShowAction; 130 QAction *mShowAction;
198 QAction *mEditAction; 131 QAction *mEditAction;
199 QAction *mDeleteAction; 132 QAction *mDeleteAction;
200 QAction *mCloneAction; 133 QAction *mCloneAction;
201 QAction *mMoveAction; 134 QAction *mMoveAction;
202 QAction *mBeamAction; 135 QAction *mBeamAction;
203 QAction *mCancelAction; 136 QAction *mCancelAction;
204 137
205 138
206 void closeEvent( QCloseEvent* ce ); 139 void closeEvent( QCloseEvent* ce );
207 SimpleAlarmClient mAlarmClient; 140 SimpleAlarmClient mAlarmClient;
208 QTimer mSaveTimer; 141 QTimer mSaveTimer;
209 bool mBlockSaveFlag; 142 bool mBlockSaveFlag;
210 bool mCalendarModifiedFlag; 143 bool mCalendarModifiedFlag;
211 QPixmap loadPixmap( QString ); 144 QPixmap loadPixmap( QString );
212 QDialog * mSyncActionDialog;
213}; 145};
214 146
215 147
216#endif 148#endif
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index a9ea330..0a2f5f1 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -1,72 +1,75 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35 35
36#include "kpimprefs.h" 36#include "kpimprefs.h"
37 37
38KPimPrefs::KPimPrefs( const QString &name ) : 38KPimPrefs::KPimPrefs( const QString &name ) :
39 KPrefs( name ) 39 KPrefs( name )
40{ 40{
41 config()->setGroup("General");
42 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
43 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
41} 44}
42 45
43KPimPrefs::~KPimPrefs() 46KPimPrefs::~KPimPrefs()
44{ 47{
45} 48}
46 49
47void KPimPrefs::usrSetDefaults() 50void KPimPrefs::usrSetDefaults()
48{ 51{
49 setCategoryDefaults(); 52 setCategoryDefaults();
50} 53}
51 54
52void KPimPrefs::usrReadConfig() 55void KPimPrefs::usrReadConfig()
53{ 56{
54 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; 57 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl;
55 58
56 config()->setGroup("General"); 59 config()->setGroup("General");
57 mCustomCategories = config()->readListEntry("Custom Categories"); 60 mCustomCategories = config()->readListEntry("Custom Categories");
58 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 61 if (mCustomCategories.isEmpty()) setCategoryDefaults();
59} 62}
60 63
61 64
62void KPimPrefs::usrWriteConfig() 65void KPimPrefs::usrWriteConfig()
63{ 66{
64 config()->setGroup("General"); 67 config()->setGroup("General");
65 config()->writeEntry("Custom Categories",mCustomCategories); 68 config()->writeEntry("Custom Categories",mCustomCategories);
66} 69}
67 70
68void KPimPrefs::setCategoryDefaults() 71void KPimPrefs::setCategoryDefaults()
69{ 72{
70 // empty implementation 73 // empty implementation
71} 74}
72 75
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index 6f92919..fde8093 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -1,69 +1,70 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KPIMPREFS_H 31#ifndef KPIMPREFS_H
32#define KPIMPREFS_H 32#define KPIMPREFS_H
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35 35
36#include "kprefs.h" 36#include "kprefs.h"
37 37
38class KPimPrefs : public KPrefs 38class KPimPrefs : public KPrefs
39{ 39{
40 public: 40 public:
41 41
42 KPimPrefs( const QString &name = QString::null ); 42 KPimPrefs( const QString &name = QString::null );
43 43
44 virtual ~KPimPrefs(); 44 virtual ~KPimPrefs();
45 45
46 /** Set preferences to default values */ 46 /** Set preferences to default values */
47 void usrSetDefaults(); 47 void usrSetDefaults();
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 58 QString mPassiveSyncPort;
59 QString mPassiveSyncPw;
59 60
60 61
61 62
62 protected: 63 protected:
63 virtual void setCategoryDefaults(); 64 virtual void setCategoryDefaults();
64 65
65 66
66 67
67}; 68};
68 69
69#endif 70#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index c0cc840..5d48884 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,663 +1,1158 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h>
35 36
36#include <qdir.h> 37#include <qdir.h>
37#include <qprogressbar.h> 38#include <qprogressbar.h>
38#include <qpopupmenu.h> 39#include <qpopupmenu.h>
39#include <qpushbutton.h> 40#include <qpushbutton.h>
40#include <qradiobutton.h> 41#include <qradiobutton.h>
41#include <qbuttongroup.h> 42#include <qbuttongroup.h>
42#include <qtimer.h> 43#include <qtimer.h>
43#include <qmessagebox.h> 44#include <qmessagebox.h>
44#include <qapplication.h> 45#include <qapplication.h>
45#include <qlineedit.h> 46#include <qlineedit.h>
46#include <qdialog.h> 47#include <qdialog.h>
47#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h>
50#include <qlabel.h>
48 51
49#include <klocale.h> 52#include <klocale.h>
50#include <kglobal.h> 53#include <kglobal.h>
51#include <kconfig.h> 54#include <kconfig.h>
52#include <kfiledialog.h> 55#include <kfiledialog.h>
53 56
54KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
55 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
56{ 59{
60 mServerSocket = 0;
57 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
58 bar->setCaption (""); 62 bar->setCaption ("");
59 63
60 int w = 300; 64 int w = 300;
61 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
62 w = 220; 66 w = 220;
63 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
64 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
65 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
66 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
67 71
68} 72}
69 73
70KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
71{ 75{
72 delete bar; 76 delete bar;
73} 77}
74 78
75 79//LR ok
76void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
77{ 81{
78 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
79 mSyncMenu->clear(); 83 mSyncMenu->clear();
80 84
81 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
82 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 }
92 mSyncMenu->insertSeparator();
83 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
84 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
85 95
86 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
87 config.setGroup("General"); 97 config.setGroup("General");
88 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
89 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
90 if ( prof.count() < 3 ) { 100 if ( prof.count() < 2 ) {
91 prof.clear(); 101 prof.clear();
92 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
93 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
94 prof << i18n("Last_file");
95 KSyncProfile* temp = new KSyncProfile (); 104 KSyncProfile* temp = new KSyncProfile ();
96 temp->setName( prof[0] ); 105 temp->setName( prof[0] );
97 temp->writeConfig(&config); 106 temp->writeConfig(&config);
98 temp->setName( prof[1] ); 107 temp->setName( prof[1] );
99 temp->writeConfig(&config); 108 temp->writeConfig(&config);
100 temp->setName( prof[2] );
101 temp->writeConfig(&config);
102 config.setGroup("General"); 109 config.setGroup("General");
103 config.writeEntry("SyncProfileNames",prof); 110 config.writeEntry("SyncProfileNames",prof);
104 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 111 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
105 config.sync(); 112 config.sync();
106 delete temp; 113 delete temp;
107 } 114 }
108 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
109 mSyncProfileNames = prof; 116 mSyncProfileNames = prof;
110 unsigned int i; 117 unsigned int i;
111 for ( i = 0; i < prof.count(); ++i ) { 118 for ( i = 0; i < prof.count(); ++i ) {
112 mSyncMenu->insertItem( prof[i], 1000+i ); 119 mSyncMenu->insertItem( prof[i], 1000+i );
113 if ( i == 2 ) 120 if ( i == 2 )
114 mSyncMenu->insertSeparator(); 121 mSyncMenu->insertSeparator();
115 } 122 }
116 QDir app_dir; 123 QDir app_dir;
117 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 124 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
118 if ( mTargetApp == PWMPI) { 125 if ( mTargetApp == PWMPI) {
119 mSyncMenu->removeItem( 1000 ); 126 mSyncMenu->removeItem( 1000 );
120 } 127 }
121 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
122 mSyncMenu->setItemEnabled( 1000, false ); 129 mSyncMenu->setItemEnabled( 1000, false );
123 } 130 }
124} 131}
125 132
126void KSyncManager::slotSyncMenu( int action ) 133void KSyncManager::slotSyncMenu( int action )
127{ 134{
128 //qDebug("syncaction %d ", action); 135 //qDebug("syncaction %d ", action);
129 if ( action == 0 ) { 136 if ( action == 0 ) {
130 137
131 // seems to be a Qt2 event handling bug 138 // seems to be a Qt2 event handling bug
132 // syncmenu.clear causes a segfault at first time 139 // syncmenu.clear causes a segfault at first time
133 // when we call it after the main event loop, it is ok 140 // when we call it after the main event loop, it is ok
134 // same behaviour when calling OM/Pi via QCOP for the first time 141 // same behaviour when calling OM/Pi via QCOP for the first time
135 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
136 //confSync(); 143 //confSync();
137 144
138 return; 145 return;
139 } 146 }
140 if ( action == 1 ) { 147 if ( action == 1 ) {
141 multiSync( true ); 148 multiSync( true );
142 return; 149 return;
143 } 150 }
151 if ( action == 2 ) {
152 enableQuick();
153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
154 return;
155 }
156 if ( action == 3 ) {
157 delete mServerSocket;
158 mServerSocket = 0;
159 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
160 return;
161 }
144 162
145 if (blockSave()) 163 if (blockSave())
146 return; 164 return;
147 165
148 setBlockSave(true); 166 setBlockSave(true);
149 167
150 mCurrentSyncProfile = action - 1000 ; 168 mCurrentSyncProfile = action - 1000 ;
151 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 169 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
152 mCurrentSyncName = mLocalMachineName ; 170 mCurrentSyncName = mLocalMachineName ;
153 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
154 KSyncProfile* temp = new KSyncProfile (); 172 KSyncProfile* temp = new KSyncProfile ();
155 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
156 temp->readConfig(&config); 174 temp->readConfig(&config);
157 mAskForPreferences = temp->getAskForPreferences(); 175 mAskForPreferences = temp->getAskForPreferences();
158 mSyncAlgoPrefs = temp->getSyncPrefs(); 176 mSyncAlgoPrefs = temp->getSyncPrefs();
159 mWriteBackFile = temp->getWriteBackFile(); 177 mWriteBackFile = temp->getWriteBackFile();
160 mWriteBackExistingOnly = temp->getWriteBackExisting(); 178 mWriteBackExistingOnly = temp->getWriteBackExisting();
161 mWriteBackInFuture = 0; 179 mWriteBackInFuture = 0;
162 if ( temp->getWriteBackFuture() ) 180 if ( temp->getWriteBackFuture() )
163 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
164 mShowSyncSummary = temp->getShowSummaryAfterSync(); 182 mShowSyncSummary = temp->getShowSummaryAfterSync();
165 if ( action == 1000 ) { 183 if ( action == 1000 ) {
166 syncSharp(); 184 syncSharp();
167 185
168 } else if ( action == 1001 ) { 186 } else if ( action == 1001 ) {
169 syncLocalFile(); 187 syncLocalFile();
170 188
171 } else if ( action == 1002 ) { 189 } else if ( action == 1002 ) {
172 quickSyncLocalFile(); 190 quickSyncLocalFile();
173 191
174 } else if ( action >= 1003 ) { 192 } else if ( action >= 1003 ) {
175 if ( temp->getIsLocalFileSync() ) { 193 if ( temp->getIsLocalFileSync() ) {
176 switch(mTargetApp) 194 switch(mTargetApp)
177 { 195 {
178 case (KAPI): 196 case (KAPI):
179 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
180 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 198 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
181 break; 199 break;
182 case (KOPI): 200 case (KOPI):
183 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 201 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
184 mLastSyncedLocalFile = temp->getRemoteFileName(); 202 mLastSyncedLocalFile = temp->getRemoteFileName();
185 break; 203 break;
186 case (PWMPI): 204 case (PWMPI):
187 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
188 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
189 break; 207 break;
190 default: 208 default:
191 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
192 break; 210 break;
193 211
194 } 212 }
195 } else { 213 } else {
196 if ( temp->getIsPhoneSync() ) { 214 if ( temp->getIsPhoneSync() ) {
197 mPhoneDevice = temp->getPhoneDevice( ) ; 215 mPhoneDevice = temp->getPhoneDevice( ) ;
198 mPhoneConnection = temp->getPhoneConnection( ); 216 mPhoneConnection = temp->getPhoneConnection( );
199 mPhoneModel = temp->getPhoneModel( ); 217 mPhoneModel = temp->getPhoneModel( );
200 syncPhone(); 218 syncPhone();
201 } else 219 } else if ( temp->getIsPiSync() ) {
220 mPassWordPiSync = temp->getRemotePw();
221 mActiveSyncPort = temp->getRemotePort();
222 mActiveSyncIP = temp->getRemoteIP();
223 syncPi();
224 }
202 syncRemote( temp ); 225 syncRemote( temp );
203 226
204 } 227 }
205 } 228 }
206 delete temp; 229 delete temp;
207 setBlockSave(false); 230 setBlockSave(false);
208} 231}
232void KSyncManager::enableQuick()
233{
234 QDialog dia ( 0, "input-dialog", true );
235 QLineEdit lab ( &dia );
236 QVBoxLayout lay( &dia );
237 lab.setText( mPrefs->mPassiveSyncPort );
238 lay.setMargin(7);
239 lay.setSpacing(7);
240 int po = 9197+mTargetApp;
241 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
242 lay.addWidget( &label);
243 lay.addWidget( &lab);
244
245 QLineEdit lepw ( &dia );
246 lepw.setText( mPrefs->mPassiveSyncPw );
247 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
248 lay.addWidget( &label2);
249 lay.addWidget( &lepw);
250 dia.setFixedSize( 230,80 );
251 dia.setCaption( i18n("Enter port for Pi-Sync") );
252 QPushButton pb ( "OK", &dia);
253 lay.addWidget( &pb );
254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
255 dia.show();
256 if ( ! dia.exec() )
257 return;
258 dia.hide();
259 qApp->processEvents();
260 mPrefs->mPassiveSyncPw = lepw.text();
261 mPrefs->mPassiveSyncPort = lab.text();
262 bool ok;
263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
264 if ( ! ok ) {
265 KMessageBox::information( 0, i18n("No valid port"));
266 return;
267 }
268 //qDebug("port %d ", port);
269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
270 mServerSocket->setFileName( defaultFileName() );
271 //qDebug("connected ");
272 if ( !mServerSocket->ok() ) {
273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
274 delete mServerSocket;
275 mServerSocket = 0;
276 return;
277 }
278 connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
279 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
280}
209 281
210void KSyncManager::syncLocalFile() 282void KSyncManager::syncLocalFile()
211{ 283{
212 284
213 QString fn =mLastSyncedLocalFile; 285 QString fn =mLastSyncedLocalFile;
214 QString ext; 286 QString ext;
215 287
216 switch(mTargetApp) 288 switch(mTargetApp)
217 { 289 {
218 case (KAPI): 290 case (KAPI):
219 ext = "(*.vcf)"; 291 ext = "(*.vcf)";
220 break; 292 break;
221 case (KOPI): 293 case (KOPI):
222 ext = "(*.ics/*.vcs)"; 294 ext = "(*.ics/*.vcs)";
223 break; 295 break;
224 case (PWMPI): 296 case (PWMPI):
225 ext = "(*.pwm)"; 297 ext = "(*.pwm)";
226 break; 298 break;
227 default: 299 default:
228 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 300 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
229 break; 301 break;
230 302
231 } 303 }
232 304
233 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 305 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
234 if ( fn == "" ) 306 if ( fn == "" )
235 return; 307 return;
236 if ( syncWithFile( fn, false ) ) { 308 if ( syncWithFile( fn, false ) ) {
237 qDebug("syncLocalFile() successful "); 309 qDebug("syncLocalFile() successful ");
238 } 310 }
239 311
240} 312}
241bool KSyncManager::syncWithFile( QString fn , bool quick ) 313bool KSyncManager::syncWithFile( QString fn , bool quick )
242{ 314{
243 bool ret = false; 315 bool ret = false;
244 QFileInfo info; 316 QFileInfo info;
245 info.setFile( fn ); 317 info.setFile( fn );
246 QString mess; 318 QString mess;
247 bool loadbup = true; 319 bool loadbup = true;
248 if ( !info. exists() ) { 320 if ( !info. exists() ) {
249 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 321 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
250 int result = QMessageBox::warning( mParent, i18n("Warning!"), 322 int result = QMessageBox::warning( mParent, i18n("Warning!"),
251 mess ); 323 mess );
252 return ret; 324 return ret;
253 } 325 }
254 int result = 0; 326 int result = 0;
255 if ( !quick ) { 327 if ( !quick ) {
256 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 328 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
257 result = QMessageBox::warning( mParent, i18n("Warning!"), 329 result = QMessageBox::warning( mParent, i18n("Warning!"),
258 mess, 330 mess,
259 i18n("Sync"), i18n("Cancel"), 0, 331 i18n("Sync"), i18n("Cancel"), 0,
260 0, 1 ); 332 0, 1 );
261 if ( result ) 333 if ( result )
262 return false; 334 return false;
263 } 335 }
264 if ( mAskForPreferences ) 336 if ( mAskForPreferences )
265 edit_sync_options(); 337 edit_sync_options();
266 if ( result == 0 ) { 338 if ( result == 0 ) {
267 //qDebug("Now sycing ... "); 339 //qDebug("Now sycing ... ");
268 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 340 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
269 mParent->setCaption( i18n("Synchronization successful") ); 341 mParent->setCaption( i18n("Synchronization successful") );
270 else 342 else
271 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 343 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
272 if ( ! quick ) 344 if ( ! quick )
273 mLastSyncedLocalFile = fn; 345 mLastSyncedLocalFile = fn;
274 mImplementation->sync_setModified();
275 } 346 }
276 return ret; 347 return ret;
277} 348}
278void KSyncManager::quickSyncLocalFile() 349void KSyncManager::quickSyncLocalFile()
279{ 350{
280 351
281 if ( syncWithFile( mLastSyncedLocalFile, false ) ) { 352 if ( syncWithFile( mLastSyncedLocalFile, false ) ) {
282 qDebug("quick syncLocalFile() successful "); 353 qDebug("quick syncLocalFile() successful ");
283 354
284 } 355 }
285} 356}
286void KSyncManager::multiSync( bool askforPrefs ) 357void KSyncManager::multiSync( bool askforPrefs )
287{ 358{
288 if (blockSave()) 359 if (blockSave())
289 return; 360 return;
290 setBlockSave(true); 361 setBlockSave(true);
291 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 362 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
292 if ( QMessageBox::information( mParent, i18n("Sync"), 363 if ( QMessageBox::information( mParent, i18n("Sync"),
293 question, 364 question,
294 i18n("Yes"), i18n("No"), 365 i18n("Yes"), i18n("No"),
295 0, 0 ) != 0 ) { 366 0, 0 ) != 0 ) {
296 setBlockSave(false); 367 setBlockSave(false);
297 mParent->setCaption(i18n("Aborted! Nothing synced!")); 368 mParent->setCaption(i18n("Aborted! Nothing synced!"));
298 return; 369 return;
299 } 370 }
300 mCurrentSyncDevice = i18n("Multiple profiles") ; 371 mCurrentSyncDevice = i18n("Multiple profiles") ;
301 mSyncAlgoPrefs = mRingSyncAlgoPrefs; 372 mSyncAlgoPrefs = mRingSyncAlgoPrefs;
302 if ( askforPrefs ) { 373 if ( askforPrefs ) {
303 edit_sync_options(); 374 edit_sync_options();
304 mRingSyncAlgoPrefs = mSyncAlgoPrefs; 375 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
305 } 376 }
306 mParent->setCaption(i18n("Multiple sync started.") ); 377 mParent->setCaption(i18n("Multiple sync started.") );
307 qApp->processEvents(); 378 qApp->processEvents();
308 int num = ringSync() ; 379 int num = ringSync() ;
309 if ( num > 1 ) 380 if ( num > 1 )
310 ringSync(); 381 ringSync();
311 setBlockSave(false); 382 setBlockSave(false);
312 if ( num ) 383 if ( num )
313 mImplementation->sync_save(); 384 emit save();
314 if ( num ) 385 if ( num )
315 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 386 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
316 else 387 else
317 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 388 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
318 return; 389 return;
319} 390}
320int KSyncManager::ringSync() 391int KSyncManager::ringSync()
321{ 392{
322 int syncedProfiles = 0; 393 int syncedProfiles = 0;
323 unsigned int i; 394 unsigned int i;
324 QTime timer; 395 QTime timer;
325 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 396 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
326 QStringList syncProfileNames = mSyncProfileNames; 397 QStringList syncProfileNames = mSyncProfileNames;
327 KSyncProfile* temp = new KSyncProfile (); 398 KSyncProfile* temp = new KSyncProfile ();
328 mAskForPreferences = false; 399 mAskForPreferences = false;
329 for ( i = 0; i < syncProfileNames.count(); ++i ) { 400 for ( i = 0; i < syncProfileNames.count(); ++i ) {
330 mCurrentSyncProfile = i; 401 mCurrentSyncProfile = i;
331 temp->setName(syncProfileNames[mCurrentSyncProfile]); 402 temp->setName(syncProfileNames[mCurrentSyncProfile]);
332 temp->readConfig(&config); 403 temp->readConfig(&config);
333 404
334 QString includeInRingSync; 405 QString includeInRingSync;
335 switch(mTargetApp) 406 switch(mTargetApp)
336 { 407 {
337 case (KAPI): 408 case (KAPI):
338 includeInRingSync = temp->getIncludeInRingSyncAB(); 409 includeInRingSync = temp->getIncludeInRingSyncAB();
339 break; 410 break;
340 case (KOPI): 411 case (KOPI):
341 includeInRingSync = temp->getIncludeInRingSync(); 412 includeInRingSync = temp->getIncludeInRingSync();
342 break; 413 break;
343 case (PWMPI): 414 case (PWMPI):
344 includeInRingSync = temp->getIncludeInRingSyncPWM(); 415 includeInRingSync = temp->getIncludeInRingSyncPWM();
345 break; 416 break;
346 default: 417 default:
347 qDebug("KSyncManager::ringSync: invalid apptype selected"); 418 qDebug("KSyncManager::ringSync: invalid apptype selected");
348 break; 419 break;
349 420
350 } 421 }
351 422
352 423
353 if ( includeInRingSync && ( i < 1 || i > 2 )) { 424 if ( includeInRingSync && ( i < 1 || i > 2 )) {
354 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 425 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
355 ++syncedProfiles; 426 ++syncedProfiles;
356 // mAskForPreferences = temp->getAskForPreferences(); 427 // mAskForPreferences = temp->getAskForPreferences();
357 mWriteBackFile = temp->getWriteBackFile(); 428 mWriteBackFile = temp->getWriteBackFile();
358 mWriteBackExistingOnly = temp->getWriteBackExisting(); 429 mWriteBackExistingOnly = temp->getWriteBackExisting();
359 mWriteBackInFuture = 0; 430 mWriteBackInFuture = 0;
360 if ( temp->getWriteBackFuture() ) 431 if ( temp->getWriteBackFuture() )
361 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 432 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
362 mShowSyncSummary = false; 433 mShowSyncSummary = false;
363 mCurrentSyncDevice = syncProfileNames[i] ; 434 mCurrentSyncDevice = syncProfileNames[i] ;
364 mCurrentSyncName = mLocalMachineName; 435 mCurrentSyncName = mLocalMachineName;
365 if ( i == 0 ) { 436 if ( i == 0 ) {
366 syncSharp(); 437 syncSharp();
367 } else { 438 } else {
368 if ( temp->getIsLocalFileSync() ) { 439 if ( temp->getIsLocalFileSync() ) {
369 switch(mTargetApp) 440 switch(mTargetApp)
370 { 441 {
371 case (KAPI): 442 case (KAPI):
372 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 443 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
373 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 444 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
374 break; 445 break;
375 case (KOPI): 446 case (KOPI):
376 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 447 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
377 mLastSyncedLocalFile = temp->getRemoteFileName(); 448 mLastSyncedLocalFile = temp->getRemoteFileName();
378 break; 449 break;
379 case (PWMPI): 450 case (PWMPI):
380 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 451 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
381 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 452 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
382 break; 453 break;
383 default: 454 default:
384 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 455 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
385 break; 456 break;
386 } 457 }
387 } else { 458 } else {
388 if ( temp->getIsPhoneSync() ) { 459 if ( temp->getIsPhoneSync() ) {
389 mPhoneDevice = temp->getPhoneDevice( ) ; 460 mPhoneDevice = temp->getPhoneDevice( ) ;
390 mPhoneConnection = temp->getPhoneConnection( ); 461 mPhoneConnection = temp->getPhoneConnection( );
391 mPhoneModel = temp->getPhoneModel( ); 462 mPhoneModel = temp->getPhoneModel( );
392 syncPhone(); 463 syncPhone();
393 } else 464 } else
394 syncRemote( temp, false ); 465 syncRemote( temp, false );
395 466
396 } 467 }
397 } 468 }
398 timer.start(); 469 timer.start();
399 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); 470 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") );
400 while ( timer.elapsed () < 2000 ) { 471 while ( timer.elapsed () < 2000 ) {
401 qApp->processEvents(); 472 qApp->processEvents();
402#ifndef _WIN32_ 473#ifndef _WIN32_
403 sleep (1); 474 sleep (1);
404#endif 475#endif
405 } 476 }
406 477
407 } 478 }
408 479
409 } 480 }
410 delete temp; 481 delete temp;
411 return syncedProfiles; 482 return syncedProfiles;
412} 483}
413 484
414void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 485void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
415{ 486{
416 QString question; 487 QString question;
417 if ( ask ) { 488 if ( ask ) {
418 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 489 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
419 if ( QMessageBox::information( mParent, i18n("Sync"), 490 if ( QMessageBox::information( mParent, i18n("Sync"),
420 question, 491 question,
421 i18n("Yes"), i18n("No"), 492 i18n("Yes"), i18n("No"),
422 0, 0 ) != 0 ) 493 0, 0 ) != 0 )
423 return; 494 return;
424 } 495 }
425 496
426 QString preCommand; 497 QString preCommand;
427 QString localTempFile; 498 QString localTempFile;
428 QString postCommand; 499 QString postCommand;
429 500
430 switch(mTargetApp) 501 switch(mTargetApp)
431 { 502 {
432 case (KAPI): 503 case (KAPI):
433 preCommand = prof->getPreSyncCommandAB(); 504 preCommand = prof->getPreSyncCommandAB();
434 postCommand = prof->getPostSyncCommandAB(); 505 postCommand = prof->getPostSyncCommandAB();
435 localTempFile = prof->getLocalTempFileAB(); 506 localTempFile = prof->getLocalTempFileAB();
436 break; 507 break;
437 case (KOPI): 508 case (KOPI):
438 preCommand = prof->getPreSyncCommand(); 509 preCommand = prof->getPreSyncCommand();
439 postCommand = prof->getPostSyncCommand(); 510 postCommand = prof->getPostSyncCommand();
440 localTempFile = prof->getLocalTempFile(); 511 localTempFile = prof->getLocalTempFile();
441 break; 512 break;
442 case (PWMPI): 513 case (PWMPI):
443 preCommand = prof->getPreSyncCommandPWM(); 514 preCommand = prof->getPreSyncCommandPWM();
444 postCommand = prof->getPostSyncCommandPWM(); 515 postCommand = prof->getPostSyncCommandPWM();
445 localTempFile = prof->getLocalTempFilePWM(); 516 localTempFile = prof->getLocalTempFilePWM();
446 break; 517 break;
447 default: 518 default:
448 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 519 qDebug("KSyncManager::syncRemote: invalid apptype selected");
449 break; 520 break;
450 } 521 }
451 522
452 523
453 int fi; 524 int fi;
454 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 525 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
455 QString pwd = getPassword(); 526 QString pwd = getPassword();
456 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 527 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
457 528
458 } 529 }
459 int maxlen = 30; 530 int maxlen = 30;
460 if ( QApplication::desktop()->width() > 320 ) 531 if ( QApplication::desktop()->width() > 320 )
461 maxlen += 25; 532 maxlen += 25;
462 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); 533 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) );
463 int fileSize = 0; 534 int fileSize = 0;
464 int result = system ( preCommand ); 535 int result = system ( preCommand );
465 // 0 : okay 536 // 0 : okay
466 // 256: no such file or dir 537 // 256: no such file or dir
467 // 538 //
468 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 539 qDebug("KO: Remote copy result(0 = okay): %d ",result );
469 if ( result != 0 ) { 540 if ( result != 0 ) {
470 unsigned int len = maxlen; 541 unsigned int len = maxlen;
471 while ( len < preCommand.length() ) { 542 while ( len < preCommand.length() ) {
472 preCommand.insert( len , "\n" ); 543 preCommand.insert( len , "\n" );
473 len += maxlen +2; 544 len += maxlen +2;
474 } 545 }
475 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 546 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
476 QMessageBox::information( mParent, i18n("Sync - ERROR"), 547 QMessageBox::information( mParent, i18n("Sync - ERROR"),
477 question, 548 question,
478 i18n("Okay!")) ; 549 i18n("Okay!")) ;
479 mParent->setCaption (""); 550 mParent->setCaption ("");
480 return; 551 return;
481 } 552 }
482 mParent->setCaption ( i18n( "Copying succeed." ) ); 553 mParent->setCaption ( i18n( "Copying succeed." ) );
483 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 554 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
484 555
485 556
486 557
487 if ( syncWithFile( localTempFile, true ) ) { 558 if ( syncWithFile( localTempFile, true ) ) {
488// Event* e = mView->getLastSyncEvent(); 559// Event* e = mView->getLastSyncEvent();
489// e->setReadOnly( false ); 560// e->setReadOnly( false );
490// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 561// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
491// e->setReadOnly( true ); 562// e->setReadOnly( true );
492 if ( mWriteBackFile ) { 563 if ( mWriteBackFile ) {
493 int fi; 564 int fi;
494 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 565 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
495 QString pwd = getPassword(); 566 QString pwd = getPassword();
496 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 567 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
497 568
498 } 569 }
499 mParent->setCaption ( i18n( "Writing back file ..." ) ); 570 mParent->setCaption ( i18n( "Writing back file ..." ) );
500 result = system ( postCommand ); 571 result = system ( postCommand );
501 qDebug("Writing back file result: %d ", result); 572 qDebug("Writing back file result: %d ", result);
502 if ( result != 0 ) { 573 if ( result != 0 ) {
503 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 574 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
504 return; 575 return;
505 } else { 576 } else {
506 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 577 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) );
507 } 578 }
508 } 579 }
509 } 580 }
510 return; 581 return;
511} 582}
512 583
513void KSyncManager::edit_sync_options() 584void KSyncManager::edit_sync_options()
514{ 585{
515 //mDialogManager->showSyncOptions(); 586 //mDialogManager->showSyncOptions();
516 //mSyncAlgoPrefs 587 //mSyncAlgoPrefs
517 QDialog dia( mParent, "dia", true ); 588 QDialog dia( mParent, "dia", true );
518 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 589 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
519 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 590 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
520 QVBoxLayout lay ( &dia ); 591 QVBoxLayout lay ( &dia );
521 lay.setSpacing( 2 ); 592 lay.setSpacing( 2 );
522 lay.setMargin( 3 ); 593 lay.setMargin( 3 );
523 lay.addWidget(&gr); 594 lay.addWidget(&gr);
524 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 595 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
525 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 596 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
526 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 597 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
527 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 598 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
528 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 599 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
529 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 600 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
530 //QRadioButton both( i18n("Take both on conflict"), &gr ); 601 //QRadioButton both( i18n("Take both on conflict"), &gr );
531 QPushButton pb ( "OK", &dia); 602 QPushButton pb ( "OK", &dia);
532 lay.addWidget( &pb ); 603 lay.addWidget( &pb );
533 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 604 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
534 switch ( mSyncAlgoPrefs ) { 605 switch ( mSyncAlgoPrefs ) {
535 case 0: 606 case 0:
536 loc.setChecked( true); 607 loc.setChecked( true);
537 break; 608 break;
538 case 1: 609 case 1:
539 rem.setChecked( true ); 610 rem.setChecked( true );
540 break; 611 break;
541 case 2: 612 case 2:
542 newest.setChecked( true); 613 newest.setChecked( true);
543 break; 614 break;
544 case 3: 615 case 3:
545 ask.setChecked( true); 616 ask.setChecked( true);
546 break; 617 break;
547 case 4: 618 case 4:
548 f_loc.setChecked( true); 619 f_loc.setChecked( true);
549 break; 620 break;
550 case 5: 621 case 5:
551 f_rem.setChecked( true); 622 f_rem.setChecked( true);
552 break; 623 break;
553 case 6: 624 case 6:
554 // both.setChecked( true); 625 // both.setChecked( true);
555 break; 626 break;
556 default: 627 default:
557 break; 628 break;
558 } 629 }
559 if ( dia.exec() ) { 630 if ( dia.exec() ) {
560 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 631 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
561 } 632 }
562 633
563 634
564} 635}
565QString KSyncManager::getPassword( ) 636QString KSyncManager::getPassword( )
566{ 637{
567 QString retfile = ""; 638 QString retfile = "";
568 QDialog dia ( mParent, "input-dialog", true ); 639 QDialog dia ( mParent, "input-dialog", true );
569 QLineEdit lab ( &dia ); 640 QLineEdit lab ( &dia );
570 lab.setEchoMode( QLineEdit::Password ); 641 lab.setEchoMode( QLineEdit::Password );
571 QVBoxLayout lay( &dia ); 642 QVBoxLayout lay( &dia );
572 lay.setMargin(7); 643 lay.setMargin(7);
573 lay.setSpacing(7); 644 lay.setSpacing(7);
574 lay.addWidget( &lab); 645 lay.addWidget( &lab);
575 dia.setFixedSize( 230,50 ); 646 dia.setFixedSize( 230,50 );
576 dia.setCaption( i18n("Enter password") ); 647 dia.setCaption( i18n("Enter password") );
577 QPushButton pb ( "OK", &dia); 648 QPushButton pb ( "OK", &dia);
578 lay.addWidget( &pb ); 649 lay.addWidget( &pb );
579 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 650 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
580 dia.show(); 651 dia.show();
581 int res = dia.exec(); 652 int res = dia.exec();
582 if ( res ) 653 if ( res )
583 retfile = lab.text(); 654 retfile = lab.text();
584 dia.hide(); 655 dia.hide();
585 qApp->processEvents(); 656 qApp->processEvents();
586 return retfile; 657 return retfile;
587 658
588} 659}
589 660
590 661
591void KSyncManager::confSync() 662void KSyncManager::confSync()
592{ 663{
593 static KSyncPrefsDialog* sp = 0; 664 static KSyncPrefsDialog* sp = 0;
594 if ( ! sp ) { 665 if ( ! sp ) {
595 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 666 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
596 } 667 }
597 sp->usrReadConfig(); 668 sp->usrReadConfig();
598#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
599 sp->showMaximized(); 670 sp->showMaximized();
600#else 671#else
601 sp->show(); 672 sp->show();
602#endif 673#endif
603 sp->exec(); 674 sp->exec();
604 mSyncProfileNames = sp->getSyncProfileNames(); 675 mSyncProfileNames = sp->getSyncProfileNames();
605 mLocalMachineName = sp->getLocalMachineName (); 676 mLocalMachineName = sp->getLocalMachineName ();
606 fillSyncMenu(); 677 fillSyncMenu();
607} 678}
608 679
609void KSyncManager::syncSharp() 680void KSyncManager::syncSharp()
610{ 681{
611 if ( ! syncExternalApplication("sharp") ) 682 if ( ! syncExternalApplication("sharp") )
612 qDebug("ERROR sync sharp ");; 683 qDebug("ERROR sync sharp ");;
613} 684}
614 685
615bool KSyncManager::syncExternalApplication(QString resource) 686bool KSyncManager::syncExternalApplication(QString resource)
616{ 687{
617 if ( mImplementation->sync_isModified() ) 688
618 mImplementation->sync_save(); 689 emit save();
619 690
620 if ( mAskForPreferences ) 691 if ( mAskForPreferences )
621 edit_sync_options(); 692 edit_sync_options();
622 693
623 qDebug("sync %s", resource.latin1()); 694 qDebug("sync %s", resource.latin1());
624 695
625 bool syncOK = mImplementation->syncExternal(this, resource); 696 bool syncOK = mImplementation->syncExternal(this, resource);
626 697
627 return syncOK; 698 return syncOK;
628 699
629} 700}
630 701
631void KSyncManager::syncPhone() 702void KSyncManager::syncPhone()
632{ 703{
633 if ( mImplementation->sync_isModified() ) 704 emit save();
634 mImplementation->sync_save();
635 705
636 qDebug("pending syncPhone(); "); 706 qDebug("pending syncPhone(); ");
637 //mView->syncPhone(); 707 //mView->syncPhone();
638 mImplementation->sync_setModified();
639 708
640} 709}
641 710
642void KSyncManager::showProgressBar(int percentage, QString caption, int total) 711void KSyncManager::showProgressBar(int percentage, QString caption, int total)
643{ 712{
644 if (!bar->isVisible()) 713 if (!bar->isVisible())
645 { 714 {
646 bar->setCaption (caption); 715 bar->setCaption (caption);
647 bar->setTotalSteps ( total ) ; 716 bar->setTotalSteps ( total ) ;
648 717
649 bar->show(); 718 bar->show();
650 } 719 }
651 720
652 bar->setProgress( percentage ); 721 bar->setProgress( percentage );
653} 722}
654 723
655void KSyncManager::hideProgressBar() 724void KSyncManager::hideProgressBar()
656{ 725{
657 bar->hide(); 726 bar->hide();
658} 727}
659 728
660bool KSyncManager::isProgressBarCanceled() 729bool KSyncManager::isProgressBarCanceled()
661{ 730{
662 return !bar->isVisible(); 731 return !bar->isVisible();
663} 732}
733
734QString KSyncManager::syncFileName()
735{
736
737 QString fn = "tempfile";
738 switch(mTargetApp)
739 {
740 case (KAPI):
741 fn = "addressbook.vcf";
742 break;
743 case (KOPI):
744 fn = "synccalendar.ics";
745 break;
746 case (PWMPI):
747 fn = "manager.pwm";
748 break;
749 default:
750 break;
751 }
752#ifdef _WIN32_
753 return locateLocal( "tmp", fn );
754#else
755 return (QString( "/tmp/" )+ fn );
756#endif
757}
758
759void KSyncManager::syncPi()
760{
761 qApp->processEvents();
762 bool ok;
763 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
764 if ( ! ok ) {
765 mParent->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
766 return;
767 }
768 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
769 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
770 mParent->setCaption( i18n("Sending request for remote file ...") );
771 commandSocket->readFile( syncFileName() );
772}
773
774void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
775{
776 qDebug("MainWindow::deleteCommandSocket %d", state);
777
778 //enum { success, errorW, errorR, quiet };
779 if ( state == KCommandSocket::errorR ) {
780 mParent->setCaption( i18n("ERROR: Receiving remote file failed.") );
781 delete s;
782 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
783 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
784 commandSocket->sendStop();
785 return;
786
787 } else if ( state == KCommandSocket::errorW ) {
788 mParent->setCaption( i18n("ERROR:Writing back file failed.") );
789
790 } else if ( state == KCommandSocket::successR ) {
791 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
792
793 } else if ( state == KCommandSocket::successW ) {
794 mParent->setCaption( i18n("Pi-Sync succesful!") );
795 }
796
797 delete s;
798}
799
800void KSyncManager::readFileFromSocket()
801{
802 QString fileName = syncFileName();
803 mParent->setCaption( i18n("Remote file saved to temp file.") );
804 if ( ! syncWithFile( fileName , true ) ) {
805 mParent->setCaption( i18n("Syncing failed.") );
806 qDebug("Syncing failed ");
807 return;
808 }
809 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
810 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
811 if ( mWriteBackFile )
812 commandSocket->writeFile( fileName );
813 else {
814 commandSocket->sendStop();
815 mParent->setCaption( i18n("Pi-Sync succesful!") );
816 }
817}
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
842{
843 mPassWord = pw;
844 mSocket = 0;
845 mSyncActionDialog = 0;
846 blockRC = false;
847};
848
849void KServerSocket::newConnection ( int socket )
850{
851 // qDebug("KServerSocket:New connection %d ", socket);
852 if ( mSocket ) {
853 qDebug("KServerSocket::newConnection Socket deleted! ");
854 delete mSocket;
855 mSocket = 0;
856 }
857 mSocket = new QSocket( this );
858 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
859 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
860 mSocket->setSocket( socket );
861}
862
863void KServerSocket::discardClient()
864{
865 //qDebug(" KServerSocket::discardClient()");
866 if ( mSocket ) {
867 delete mSocket;
868 mSocket = 0;
869 }
870 //emit endConnect();
871}
872void KServerSocket::readClient()
873{
874 if ( blockRC )
875 return;
876 if ( mSocket == 0 ) {
877 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
878 return;
879 }
880 qDebug("KServerSocket readClient()");
881 if ( mSocket->canReadLine() ) {
882 QString line = mSocket->readLine();
883 qDebug("KServerSocket readline: %s ", line.latin1());
884 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
885 if ( tokens[0] == "GET" ) {
886 if ( tokens[1] == mPassWord )
887 //emit sendFile( mSocket );
888 send_file();
889 else {
890 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
891 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
892 }
893 }
894 if ( tokens[0] == "PUT" ) {
895 if ( tokens[1] == mPassWord ) {
896 //emit getFile( mSocket );
897 blockRC = true;
898 get_file();
899 }
900 else {
901 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
902 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
903 }
904 }
905 if ( tokens[0] == "STOP" ) {
906 //emit endConnect();
907 end_connect();
908 }
909 }
910}
911void KServerSocket::end_connect()
912{
913 delete mSyncActionDialog;
914 mSyncActionDialog = 0;
915}
916void KServerSocket::send_file()
917{
918 //qDebug("MainWindow::sendFile(QSocket* s) ");
919 if ( mSyncActionDialog )
920 delete mSyncActionDialog;
921 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
922 mSyncActionDialog->setCaption(i18n("Received sync request"));
923 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
924 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
925 lay->addWidget( label);
926 lay->setMargin(7);
927 lay->setSpacing(7);
928 mSyncActionDialog->setFixedSize( 230, 120);
929 mSyncActionDialog->show();
930 qDebug("KSS::saving ... ");
931 emit saveFile();
932 qApp->processEvents();
933 QString fileName = mFileName;
934 QFile file( fileName );
935 if (!file.open( IO_ReadOnly ) ) {
936 delete mSyncActionDialog;
937 mSyncActionDialog = 0;
938 qDebug("KSS::error open file ");
939 mSocket->close();
940 if ( mSocket->state() == QSocket::Idle )
941 QTimer::singleShot( 10, this , SLOT ( discardClient()));
942 return ;
943
944 }
945 mSyncActionDialog->setCaption( i18n("Sending file...") );
946 QTextStream ts( &file );
947 ts.setCodec( QTextCodec::codecForName("utf8") );
948 QTextStream os( mSocket );
949 os.setCodec( QTextCodec::codecForName("utf8") );
950 //os.setEncoding( QTextStream::UnicodeUTF8 );
951 while ( ! ts.atEnd() ) {
952 os << ts.readLine() << "\n";
953 }
954 //os << ts.read();
955 file.close();
956 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
957 mSocket->close();
958 if ( mSocket->state() == QSocket::Idle )
959 QTimer::singleShot( 10, this , SLOT ( discardClient()));
960}
961void KServerSocket::get_file()
962{
963 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
964
965 piTime.start();
966 piFileString = "";
967 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
968}
969
970
971void KServerSocket::readBackFileFromSocket()
972{
973 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
974 while ( mSocket->canReadLine () ) {
975 piTime.restart();
976 QString line = mSocket->readLine ();
977 piFileString += line;
978 //qDebug("readline: %s ", line.latin1());
979 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
980
981 }
982 if ( piTime.elapsed () < 3000 ) {
983 // wait for more
984 //qDebug("waitformore ");
985 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
986 return;
987 }
988 QString fileName = mFileName;
989 QFile file ( fileName );
990 if (!file.open( IO_WriteOnly ) ) {
991 delete mSyncActionDialog;
992 mSyncActionDialog = 0;
993 qDebug("error open cal file ");
994 piFileString = "";
995 emit file_received( false );
996 blockRC = false;
997 return ;
998
999 }
1000
1001 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1002 QTextStream ts ( &file );
1003 ts.setCodec( QTextCodec::codecForName("utf8") );
1004 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1005 ts << piFileString;
1006 mSocket->close();
1007 if ( mSocket->state() == QSocket::Idle )
1008 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1009 file.close();
1010 delete mSyncActionDialog;
1011 mSyncActionDialog = 0;
1012 piFileString = "";
1013 blockRC = false;
1014 emit file_received( true );
1015
1016}
1017
1018KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1019{
1020 mPassWord = password;
1021 mSocket = 0;
1022 mPort = port;
1023 mHost = host;
1024
1025 mRetVal = quiet;
1026 mTimerSocket = new QTimer ( this );
1027 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1028}
1029void KCommandSocket::readFile( QString fn )
1030{
1031 if ( !mSocket ) {
1032 mSocket = new QSocket( this );
1033 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1034 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1035 }
1036 mFileString = "";
1037 mFileName = fn;
1038 mFirst = true;
1039 mSocket->connectToHost( mHost, mPort );
1040 QTextStream os( mSocket );
1041 os.setEncoding( QTextStream::UnicodeUTF8 );
1042 os << "GET " << mPassWord << "\r\n";
1043 mTimerSocket->start( 10000 );
1044}
1045
1046void KCommandSocket::writeFile( QString fileName )
1047{
1048 if ( !mSocket ) {
1049 mSocket = new QSocket( this );
1050 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1051 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1052 }
1053 mFileName = fileName ;
1054 mSocket->connectToHost( mHost, mPort );
1055}
1056void KCommandSocket::writeFileToSocket()
1057{
1058 QFile file2( mFileName );
1059 if (!file2.open( IO_ReadOnly ) ) {
1060 mRetVal= errorW;
1061 mSocket->close();
1062 if ( mSocket->state() == QSocket::Idle )
1063 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1064 return ;
1065 }
1066 QTextStream ts2( &file2 );
1067 ts2.setCodec( QTextCodec::codecForName("utf8") );
1068 QTextStream os2( mSocket );
1069 os2.setCodec( QTextCodec::codecForName("utf8") );
1070 os2 << "PUT " << mPassWord << "\r\n";;
1071 while ( ! ts2.atEnd() ) {
1072 os2 << ts2.readLine() << "\n";
1073 }
1074 mRetVal= successW;
1075 file2.close();
1076 mSocket->close();
1077 if ( mSocket->state() == QSocket::Idle )
1078 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1079}
1080void KCommandSocket::sendStop()
1081{
1082 if ( !mSocket ) {
1083 mSocket = new QSocket( this );
1084 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1085 }
1086 mSocket->connectToHost( mHost, mPort );
1087 QTextStream os2( mSocket );
1088 os2.setCodec( QTextCodec::codecForName("utf8") );
1089 os2 << "STOP\r\n";
1090 mSocket->close();
1091 if ( mSocket->state() == QSocket::Idle )
1092 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1093}
1094
1095void KCommandSocket::startReadFileFromSocket()
1096{
1097 if ( ! mFirst )
1098 return;
1099 mFirst = false;
1100 mTimerSocket->stop();
1101 mFileString = "";
1102 mTime.start();
1103 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1104
1105}
1106void KCommandSocket::readFileFromSocket()
1107{
1108 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1109 while ( mSocket->canReadLine () ) {
1110 mTime.restart();
1111 QString line = mSocket->readLine ();
1112 mFileString += line;
1113 //qDebug("readline: %s ", line.latin1());
1114 }
1115 if ( mTime.elapsed () < 3000 ) {
1116 // wait for more
1117 //qDebug("waitformore ");
1118 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1119 return;
1120 }
1121 QString fileName = mFileName;
1122 QFile file ( fileName );
1123 if (!file.open( IO_WriteOnly ) ) {
1124 mFileString = "";
1125 mRetVal = errorR;
1126 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
1127 deleteSocket();
1128 return ;
1129
1130 }
1131 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1132 QTextStream ts ( &file );
1133 ts.setCodec( QTextCodec::codecForName("utf8") );
1134 ts << mFileString;
1135 file.close();
1136 mFileString = "";
1137 mRetVal = successR;
1138 mSocket->close();
1139 // if state is not idle, deleteSocket(); is called via
1140 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1141 if ( mSocket->state() == QSocket::Idle )
1142 deleteSocket();
1143}
1144
1145void KCommandSocket::deleteSocket()
1146{
1147 if ( mTimerSocket->isActive () ) {
1148 mTimerSocket->stop();
1149 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1150 mRetVal = errorR;
1151 }
1152 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1153 if ( mSocket)
1154 delete mSocket;
1155 mSocket = 0;
1156 emit commandFinished( this, mRetVal );
1157}
1158
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 6b10016..52e2772 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,147 +1,228 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20$Id$ 20$Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h>
28#include <qdatetime.h>
29#include <qserversocket.h>
30#include <qtextstream.h>
31#include <qregexp.h>
27 32
28class QPopupMenu; 33class QPopupMenu;
29class KSyncProfile; 34class KSyncProfile;
30class KPimPrefs; 35class KPimPrefs;
31class QWidget; 36class QWidget;
32class KSyncManager; 37class KSyncManager;
33class KSyncInterface; 38class KSyncInterface;
34class QProgressBar; 39class QProgressBar;
35 40
41
42class KServerSocket : public QServerSocket
43{
44 Q_OBJECT
45
46public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48
49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;};
51
52signals:
53 //void sendFile(QSocket*);
54 //void getFile(QSocket*);
55 void file_received( bool );
56 //void file_sent();
57 void saveFile();
58 void endConnect();
59private slots:
60 void discardClient();
61 void readClient();
62 void readBackFileFromSocket();
63 private :
64 bool blockRC;
65 void send_file();
66 void get_file();
67 void end_connect();
68 QDialog* mSyncActionDialog;
69 QSocket* mSocket;
70 QString mPassWord;
71 QString mFileName;
72 QTime piTime;
73 QString piFileString;
74};
75
76class KCommandSocket : public QObject
77{
78 Q_OBJECT
79public:
80 enum state { successR, errorR, successW, errorW, quiet };
81 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
82 void readFile( QString );
83 void writeFile( QString );
84 void sendStop();
85
86
87signals:
88 void commandFinished( KCommandSocket*, int );
89private slots:
90 void startReadFileFromSocket();
91 void readFileFromSocket();
92 void deleteSocket();
93 void writeFileToSocket();
94 private :
95 QSocket* mSocket;
96 QString mPassWord;
97 Q_UINT16 mPort;
98 QString mHost;
99 QString mFileName;
100 QTimer* mTimerSocket;
101 int mRetVal;
102 QTime mTime;
103 QString mFileString;
104 bool mFirst;
105};
106
107
36class KSyncManager : public QObject 108class KSyncManager : public QObject
37{ 109{
38 Q_OBJECT 110 Q_OBJECT
39 111
40 public: 112 public:
41 enum TargetApp { 113 enum TargetApp {
42 KOPI = 0, 114 KOPI = 0,
43 KAPI = 1, 115 KAPI = 1,
44 PWMPI = 2 }; 116 PWMPI = 2 };
45 117
46 118
47 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 119 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
48 ~KSyncManager() ; 120 ~KSyncManager() ;
49 121
50 bool blockSave() { return mBlockSaveFlag; } 122 bool blockSave() { return mBlockSaveFlag; }
51 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 123 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
52 124 void setDefaultFileName( QString s) { mDefFileName = s ;}
125 QString defaultFileName() { return mDefFileName ;}
126 QString syncFileName();
53 void fillSyncMenu(); 127 void fillSyncMenu();
54 128
55 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 129 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
56 QString getCurrentSyncName() { return mCurrentSyncName; } 130 QString getCurrentSyncName() { return mCurrentSyncName; }
57 131
58 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 132 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
59 void hideProgressBar(); 133 void hideProgressBar();
60 bool isProgressBarCanceled(); 134 bool isProgressBarCanceled();
61 135
62 // sync stuff 136 // sync stuff
63 QString mLocalMachineName; 137 QString mLocalMachineName;
64 QStringList mExternSyncProfiles; 138 QStringList mExternSyncProfiles;
65 QStringList mSyncProfileNames; 139 QStringList mSyncProfileNames;
66 bool mAskForPreferences; 140 bool mAskForPreferences;
67 bool mShowSyncSummary; 141 bool mShowSyncSummary;
68 bool mShowSyncEvents; 142 bool mShowSyncEvents;
69 bool mShowTodoInAgenda; 143 bool mShowTodoInAgenda;
70 bool mWriteBackExistingOnly; 144 bool mWriteBackExistingOnly;
71 int mSyncAlgoPrefs; 145 int mSyncAlgoPrefs;
72 int mRingSyncAlgoPrefs; 146 int mRingSyncAlgoPrefs;
73 bool mWriteBackFile; 147 bool mWriteBackFile;
74 int mWriteBackInFuture; 148 int mWriteBackInFuture;
75 QString mPhoneDevice; 149 QString mPhoneDevice;
76 QString mPhoneConnection; 150 QString mPhoneConnection;
77 QString mPhoneModel; 151 QString mPhoneModel;
78 QString mLastSyncedLocalFile; // save! 152 QString mLastSyncedLocalFile; // save!
153 QString mPassWordPiSync;
154 QString mActiveSyncPort;
155 QString mActiveSyncIP ;
79 156
80 157 signals:
158 void save();
159 void getFile( bool );
81 160
82 public slots: 161 public slots:
83 void slotSyncMenu( int ); 162 void slotSyncMenu( int );
84 163
85 private: 164 private:
86 // LR ******************************* 165 // LR *******************************
87 // sync stuff! 166 // sync stuff!
167 void syncPi();
168 void deleteCommandSocket(KCommandSocket*s, int state);
169 void readFileFromSocket();
170 KServerSocket * mServerSocket;
171 void enableQuick();
172 KPimPrefs* mPrefs;
173 QString mDefFileName;
88 QString mCurrentSyncDevice; 174 QString mCurrentSyncDevice;
89 QString mCurrentSyncName; 175 QString mCurrentSyncName;
90 void quickSyncLocalFile(); 176 void quickSyncLocalFile();
91 bool syncWithFile( QString fn , bool quick ); 177 bool syncWithFile( QString fn , bool quick );
92 void syncLocalFile(); 178 void syncLocalFile();
93 void syncPhone(); 179 void syncPhone();
94 void syncSharp(); 180 void syncSharp();
95 bool syncExternalApplication(QString); 181 bool syncExternalApplication(QString);
96 void multiSync( bool askforPrefs ); 182 void multiSync( bool askforPrefs );
97 int mCurrentSyncProfile ; 183 int mCurrentSyncProfile ;
98 void syncRemote( KSyncProfile* prof, bool ask = true); 184 void syncRemote( KSyncProfile* prof, bool ask = true);
99 void edit_sync_options(); 185 void edit_sync_options();
100 int ringSync(); 186 int ringSync();
101 QString getPassword( ); 187 QString getPassword( );
102 188
103 private slots: 189 private slots:
104 void confSync(); 190 void confSync();
105 // ********************* 191 // *********************
106 192
107 private: 193 private:
108 bool mBlockSaveFlag; 194 bool mBlockSaveFlag;
109 195
110 196
111 QWidget* mParent; 197 QWidget* mParent;
112 KSyncInterface* mImplementation; 198 KSyncInterface* mImplementation;
113 TargetApp mTargetApp; 199 TargetApp mTargetApp;
114 QPopupMenu* mSyncMenu; 200 QPopupMenu* mSyncMenu;
115 201
116 QProgressBar* bar; 202 QProgressBar* bar;
117 203
118 204
119 205
120 206
121 207
122}; 208};
123 209
124 210
125class KSyncInterface 211class KSyncInterface
126{ 212{
127 public: 213
214
215 public :
128 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 216 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
129 217
130 virtual bool syncExternal(KSyncManager* manager, QString resource) 218 virtual bool syncExternal(KSyncManager* manager, QString resource)
131 { 219 {
132 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. 220 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
133 return false; 221 return false;
134 } 222 }
135 223
136 //called by the syncmanager to indicate that the work has to be marked as dirty. 224
137 virtual void sync_setModified() = 0;
138
139 //called by the syncmanager to ask if the dirty flag is set.
140 virtual bool sync_isModified() = 0;
141
142 //called by the syncmanager to indicate that the work has to be saved.
143 virtual void sync_save() = 0;
144}; 225};
145 226
146 227
147#endif 228#endif