summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 11:44:35 (UTC)
committer zautrix <zautrix>2004-10-07 11:44:35 (UTC)
commit43c82cc5393522d2c34f34a4339cb6a1d1c6c555 (patch) (unidiff)
tree49916cfb6f12c846fa52f9697f9b0285c2902772
parentf0e8b8f36bccda952fa662e4faf2d58fcee67262 (diff)
downloadkdepimpi-43c82cc5393522d2c34f34a4339cb6a1d1c6c555.zip
kdepimpi-43c82cc5393522d2c34f34a4339cb6a1d1c6c555.tar.gz
kdepimpi-43c82cc5393522d2c34f34a4339cb6a1d1c6c555.tar.bz2
sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp12
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--libkdepim/ksyncmanager.cpp75
-rw-r--r--libkdepim/ksyncmanager.h4
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
5 files changed, 42 insertions, 56 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 6404410..fa80f5c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1325,1557 +1325,1563 @@ void KABCore::setDetailsVisible( bool visible )
1325 } 1325 }
1326 else { 1326 else {
1327 mViewManager->show(); 1327 mViewManager->show();
1328 mDetails->hide(); 1328 mDetails->hide();
1329 } 1329 }
1330 setJumpButtonBarVisible( !visible ); 1330 setJumpButtonBarVisible( !visible );
1331 } 1331 }
1332 1332
1333} 1333}
1334 1334
1335void KABCore::extensionChanged( int id ) 1335void KABCore::extensionChanged( int id )
1336{ 1336{
1337 //change the details view only for non desktop systems 1337 //change the details view only for non desktop systems
1338#ifndef DESKTOP_VERSION 1338#ifndef DESKTOP_VERSION
1339 1339
1340 if (id == 0) 1340 if (id == 0)
1341 { 1341 {
1342 //the user disabled the extension. 1342 //the user disabled the extension.
1343 1343
1344 if (mMultipleViewsAtOnce) 1344 if (mMultipleViewsAtOnce)
1345 { // enable detailsview again 1345 { // enable detailsview again
1346 setDetailsVisible( true ); 1346 setDetailsVisible( true );
1347 mActionDetails->setChecked( true ); 1347 mActionDetails->setChecked( true );
1348 } 1348 }
1349 else 1349 else
1350 { //go back to the listview 1350 { //go back to the listview
1351 setDetailsVisible( false ); 1351 setDetailsVisible( false );
1352 mActionDetails->setChecked( false ); 1352 mActionDetails->setChecked( false );
1353 mActionDetails->setEnabled(true); 1353 mActionDetails->setEnabled(true);
1354 } 1354 }
1355 1355
1356 } 1356 }
1357 else 1357 else
1358 { 1358 {
1359 //the user enabled the extension. 1359 //the user enabled the extension.
1360 setDetailsVisible( false ); 1360 setDetailsVisible( false );
1361 mActionDetails->setChecked( false ); 1361 mActionDetails->setChecked( false );
1362 1362
1363 if (!mMultipleViewsAtOnce) 1363 if (!mMultipleViewsAtOnce)
1364 { 1364 {
1365 mActionDetails->setEnabled(false); 1365 mActionDetails->setEnabled(false);
1366 } 1366 }
1367 1367
1368 mExtensionManager->setSelectionChanged(); 1368 mExtensionManager->setSelectionChanged();
1369 1369
1370 } 1370 }
1371 1371
1372#endif// DESKTOP_VERSION 1372#endif// DESKTOP_VERSION
1373 1373
1374} 1374}
1375 1375
1376 1376
1377void KABCore::extensionModified( const KABC::Addressee::List &list ) 1377void KABCore::extensionModified( const KABC::Addressee::List &list )
1378{ 1378{
1379 1379
1380 if ( list.count() != 0 ) { 1380 if ( list.count() != 0 ) {
1381 KABC::Addressee::List::ConstIterator it; 1381 KABC::Addressee::List::ConstIterator it;
1382 for ( it = list.begin(); it != list.end(); ++it ) 1382 for ( it = list.begin(); it != list.end(); ++it )
1383 mAddressBook->insertAddressee( *it ); 1383 mAddressBook->insertAddressee( *it );
1384 if ( list.count() > 1 ) 1384 if ( list.count() > 1 )
1385 setModified(); 1385 setModified();
1386 else 1386 else
1387 setModifiedWOrefresh(); 1387 setModifiedWOrefresh();
1388 } 1388 }
1389 if ( list.count() == 0 ) 1389 if ( list.count() == 0 )
1390 mViewManager->refreshView(); 1390 mViewManager->refreshView();
1391 else 1391 else
1392 mViewManager->refreshView( list[ 0 ].uid() ); 1392 mViewManager->refreshView( list[ 0 ].uid() );
1393 1393
1394 1394
1395 1395
1396} 1396}
1397 1397
1398QString KABCore::getNameByPhone( const QString &phone ) 1398QString KABCore::getNameByPhone( const QString &phone )
1399{ 1399{
1400#ifndef KAB_EMBEDDED 1400#ifndef KAB_EMBEDDED
1401 QRegExp r( "[/*/-/ ]" ); 1401 QRegExp r( "[/*/-/ ]" );
1402 QString localPhone( phone ); 1402 QString localPhone( phone );
1403 1403
1404 bool found = false; 1404 bool found = false;
1405 QString ownerName = ""; 1405 QString ownerName = "";
1406 KABC::AddressBook::Iterator iter; 1406 KABC::AddressBook::Iterator iter;
1407 KABC::PhoneNumber::List::Iterator phoneIter; 1407 KABC::PhoneNumber::List::Iterator phoneIter;
1408 KABC::PhoneNumber::List phoneList; 1408 KABC::PhoneNumber::List phoneList;
1409 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1409 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1410 phoneList = (*iter).phoneNumbers(); 1410 phoneList = (*iter).phoneNumbers();
1411 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1411 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1412 ++phoneIter) { 1412 ++phoneIter) {
1413 // Get rid of separator chars so just the numbers are compared. 1413 // Get rid of separator chars so just the numbers are compared.
1414 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1414 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1415 ownerName = (*iter).formattedName(); 1415 ownerName = (*iter).formattedName();
1416 found = true; 1416 found = true;
1417 } 1417 }
1418 } 1418 }
1419 } 1419 }
1420 1420
1421 return ownerName; 1421 return ownerName;
1422#else //KAB_EMBEDDED 1422#else //KAB_EMBEDDED
1423 qDebug("KABCore::getNameByPhone finsih method"); 1423 qDebug("KABCore::getNameByPhone finsih method");
1424 return ""; 1424 return "";
1425#endif //KAB_EMBEDDED 1425#endif //KAB_EMBEDDED
1426 1426
1427} 1427}
1428 1428
1429void KABCore::openConfigDialog() 1429void KABCore::openConfigDialog()
1430{ 1430{
1431 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1431 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1432 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1432 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1433 ConfigureDialog->addModule(kabcfg ); 1433 ConfigureDialog->addModule(kabcfg );
1434 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1434 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1435 ConfigureDialog->addModule(kdelibcfg ); 1435 ConfigureDialog->addModule(kdelibcfg );
1436 1436
1437 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1437 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1438 this, SLOT( configurationChanged() ) ); 1438 this, SLOT( configurationChanged() ) );
1439 connect( ConfigureDialog, SIGNAL( okClicked() ), 1439 connect( ConfigureDialog, SIGNAL( okClicked() ),
1440 this, SLOT( configurationChanged() ) ); 1440 this, SLOT( configurationChanged() ) );
1441 saveSettings(); 1441 saveSettings();
1442#ifndef DESKTOP_VERSION 1442#ifndef DESKTOP_VERSION
1443 ConfigureDialog->showMaximized(); 1443 ConfigureDialog->showMaximized();
1444#endif 1444#endif
1445 if ( ConfigureDialog->exec() ) 1445 if ( ConfigureDialog->exec() )
1446 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1446 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1447 delete ConfigureDialog; 1447 delete ConfigureDialog;
1448} 1448}
1449 1449
1450void KABCore::openLDAPDialog() 1450void KABCore::openLDAPDialog()
1451{ 1451{
1452#ifndef KAB_EMBEDDED 1452#ifndef KAB_EMBEDDED
1453 if ( !mLdapSearchDialog ) { 1453 if ( !mLdapSearchDialog ) {
1454 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1454 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1456 SLOT( refreshView() ) ); 1456 SLOT( refreshView() ) );
1457 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1457 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1458 SLOT( setModified() ) ); 1458 SLOT( setModified() ) );
1459 } else 1459 } else
1460 mLdapSearchDialog->restoreSettings(); 1460 mLdapSearchDialog->restoreSettings();
1461 1461
1462 if ( mLdapSearchDialog->isOK() ) 1462 if ( mLdapSearchDialog->isOK() )
1463 mLdapSearchDialog->exec(); 1463 mLdapSearchDialog->exec();
1464#else //KAB_EMBEDDED 1464#else //KAB_EMBEDDED
1465 qDebug("KABCore::openLDAPDialog() finsih method"); 1465 qDebug("KABCore::openLDAPDialog() finsih method");
1466#endif //KAB_EMBEDDED 1466#endif //KAB_EMBEDDED
1467} 1467}
1468 1468
1469void KABCore::print() 1469void KABCore::print()
1470{ 1470{
1471#ifndef KAB_EMBEDDED 1471#ifndef KAB_EMBEDDED
1472 KPrinter printer; 1472 KPrinter printer;
1473 if ( !printer.setup( this ) ) 1473 if ( !printer.setup( this ) )
1474 return; 1474 return;
1475 1475
1476 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1476 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1477 mViewManager->selectedUids(), this ); 1477 mViewManager->selectedUids(), this );
1478 1478
1479 wizard.exec(); 1479 wizard.exec();
1480#else //KAB_EMBEDDED 1480#else //KAB_EMBEDDED
1481 qDebug("KABCore::print() finsih method"); 1481 qDebug("KABCore::print() finsih method");
1482#endif //KAB_EMBEDDED 1482#endif //KAB_EMBEDDED
1483 1483
1484} 1484}
1485 1485
1486 1486
1487void KABCore::addGUIClient( KXMLGUIClient *client ) 1487void KABCore::addGUIClient( KXMLGUIClient *client )
1488{ 1488{
1489 if ( mGUIClient ) 1489 if ( mGUIClient )
1490 mGUIClient->insertChildClient( client ); 1490 mGUIClient->insertChildClient( client );
1491 else 1491 else
1492 KMessageBox::error( this, "no KXMLGUICLient"); 1492 KMessageBox::error( this, "no KXMLGUICLient");
1493} 1493}
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( request_file() ), this, SLOT( syncFileRequest() ) ); 1686 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1688 syncManager->setDefaultFileName( sentSyncFile()); 1688 syncManager->setDefaultFileName( sentSyncFile());
1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1690 1690
1691#endif //KAB_EMBEDDED 1691#endif //KAB_EMBEDDED
1692 initActions(); 1692 initActions();
1693 1693
1694#ifdef KAB_EMBEDDED 1694#ifdef KAB_EMBEDDED
1695 addActionsManually(); 1695 addActionsManually();
1696 //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.
1697 mXXPortManager = new XXPortManager( this, this ); 1697 mXXPortManager = new XXPortManager( this, this );
1698 1698
1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1701 // mActionQuit->plug ( mMainWindow->toolBar()); 1701 // mActionQuit->plug ( mMainWindow->toolBar());
1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1704 // mIncSearchWidget->hide(); 1704 // mIncSearchWidget->hide();
1705 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1705 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1706 SLOT( incrementalSearch( const QString& ) ) ); 1706 SLOT( incrementalSearch( const QString& ) ) );
1707 1707
1708 1708
1709 mJumpButtonBar = new JumpButtonBar( this, this ); 1709 mJumpButtonBar = new JumpButtonBar( this, this );
1710 1710
1711 topLayout->addWidget( mJumpButtonBar ); 1711 topLayout->addWidget( mJumpButtonBar );
1712//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1712//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1713 1713
1714// mMainWindow->getIconToolBar()->raise(); 1714// mMainWindow->getIconToolBar()->raise();
1715 1715
1716#endif //KAB_EMBEDDED 1716#endif //KAB_EMBEDDED
1717 1717
1718} 1718}
1719void KABCore::initActions() 1719void KABCore::initActions()
1720{ 1720{
1721//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1721//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1722 1722
1723#ifndef KAB_EMBEDDED 1723#ifndef KAB_EMBEDDED
1724 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1724 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1725 SLOT( clipboardDataChanged() ) ); 1725 SLOT( clipboardDataChanged() ) );
1726#endif //KAB_EMBEDDED 1726#endif //KAB_EMBEDDED
1727 1727
1728 // file menu 1728 // file menu
1729 if ( mIsPart ) { 1729 if ( mIsPart ) {
1730 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1730 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1731 SLOT( sendMail() ), actionCollection(), 1731 SLOT( sendMail() ), actionCollection(),
1732 "kaddressbook_mail" ); 1732 "kaddressbook_mail" );
1733 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1733 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1734 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1734 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1735 1735
1736 } else { 1736 } else {
1737 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1737 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1738 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1738 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1739 } 1739 }
1740 1740
1741 1741
1742 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1742 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1743 SLOT( save() ), actionCollection(), "file_sync" ); 1743 SLOT( save() ), actionCollection(), "file_sync" );
1744 1744
1745 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1745 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1746 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1746 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1747 1747
1748 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1748 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1749 this, SLOT( mailVCard() ), 1749 this, SLOT( mailVCard() ),
1750 actionCollection(), "file_mail_vcard"); 1750 actionCollection(), "file_mail_vcard");
1751 1751
1752 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1752 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1753 SLOT( export2phone() ), actionCollection(), 1753 SLOT( export2phone() ), actionCollection(),
1754 "kaddressbook_ex2phone" ); 1754 "kaddressbook_ex2phone" );
1755 1755
1756 mActionBeamVCard = 0; 1756 mActionBeamVCard = 0;
1757 mActionBeam = 0; 1757 mActionBeam = 0;
1758 1758
1759#ifndef DESKTOP_VERSION 1759#ifndef DESKTOP_VERSION
1760 if ( Ir::supported() ) { 1760 if ( Ir::supported() ) {
1761 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,
1762 SLOT( beamVCard() ), actionCollection(), 1762 SLOT( beamVCard() ), actionCollection(),
1763 "kaddressbook_beam_vcard" ); 1763 "kaddressbook_beam_vcard" );
1764 1764
1765 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1765 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1766 SLOT( beamMySelf() ), actionCollection(), 1766 SLOT( beamMySelf() ), actionCollection(),
1767 "kaddressbook_beam_myself" ); 1767 "kaddressbook_beam_myself" );
1768 } 1768 }
1769#endif 1769#endif
1770 1770
1771 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1771 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1772 this, SLOT( editContact2() ), 1772 this, SLOT( editContact2() ),
1773 actionCollection(), "file_properties" ); 1773 actionCollection(), "file_properties" );
1774 1774
1775#ifdef KAB_EMBEDDED 1775#ifdef KAB_EMBEDDED
1776 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1776 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1777 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1777 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1778 mMainWindow, SLOT( exit() ), 1778 mMainWindow, SLOT( exit() ),
1779 actionCollection(), "quit" ); 1779 actionCollection(), "quit" );
1780#endif //KAB_EMBEDDED 1780#endif //KAB_EMBEDDED
1781 1781
1782 // edit menu 1782 // edit menu
1783 if ( mIsPart ) { 1783 if ( mIsPart ) {
1784 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1784 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1785 SLOT( copyContacts() ), actionCollection(), 1785 SLOT( copyContacts() ), actionCollection(),
1786 "kaddressbook_copy" ); 1786 "kaddressbook_copy" );
1787 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1787 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1788 SLOT( cutContacts() ), actionCollection(), 1788 SLOT( cutContacts() ), actionCollection(),
1789 "kaddressbook_cut" ); 1789 "kaddressbook_cut" );
1790 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1790 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1791 SLOT( pasteContacts() ), actionCollection(), 1791 SLOT( pasteContacts() ), actionCollection(),
1792 "kaddressbook_paste" ); 1792 "kaddressbook_paste" );
1793 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1793 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1794 SLOT( selectAllContacts() ), actionCollection(), 1794 SLOT( selectAllContacts() ), actionCollection(),
1795 "kaddressbook_select_all" ); 1795 "kaddressbook_select_all" );
1796 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1796 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1797 SLOT( undo() ), actionCollection(), 1797 SLOT( undo() ), actionCollection(),
1798 "kaddressbook_undo" ); 1798 "kaddressbook_undo" );
1799 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1799 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1800 this, SLOT( redo() ), actionCollection(), 1800 this, SLOT( redo() ), actionCollection(),
1801 "kaddressbook_redo" ); 1801 "kaddressbook_redo" );
1802 } else { 1802 } else {
1803 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1803 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1804 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1804 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1805 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1805 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1806 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1806 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1807 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1807 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1808 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1808 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1809 } 1809 }
1810 1810
1811 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1811 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1812 Key_Delete, this, SLOT( deleteContacts() ), 1812 Key_Delete, this, SLOT( deleteContacts() ),
1813 actionCollection(), "edit_delete" ); 1813 actionCollection(), "edit_delete" );
1814 1814
1815 mActionUndo->setEnabled( false ); 1815 mActionUndo->setEnabled( false );
1816 mActionRedo->setEnabled( false ); 1816 mActionRedo->setEnabled( false );
1817 1817
1818 // settings menu 1818 // settings menu
1819#ifdef KAB_EMBEDDED 1819#ifdef KAB_EMBEDDED
1820//US special menuentry to configure the addressbook resources. On KDE 1820//US special menuentry to configure the addressbook resources. On KDE
1821// you do that through the control center !!! 1821// you do that through the control center !!!
1822 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1822 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1823 SLOT( configureResources() ), actionCollection(), 1823 SLOT( configureResources() ), actionCollection(),
1824 "kaddressbook_configure_resources" ); 1824 "kaddressbook_configure_resources" );
1825#endif //KAB_EMBEDDED 1825#endif //KAB_EMBEDDED
1826 1826
1827 if ( mIsPart ) { 1827 if ( mIsPart ) {
1828 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1828 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1829 SLOT( openConfigDialog() ), actionCollection(), 1829 SLOT( openConfigDialog() ), actionCollection(),
1830 "kaddressbook_configure" ); 1830 "kaddressbook_configure" );
1831 1831
1832 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1832 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1833 this, SLOT( configureKeyBindings() ), actionCollection(), 1833 this, SLOT( configureKeyBindings() ), actionCollection(),
1834 "kaddressbook_configure_shortcuts" ); 1834 "kaddressbook_configure_shortcuts" );
1835#ifdef KAB_EMBEDDED 1835#ifdef KAB_EMBEDDED
1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1837 mActionConfigureToolbars->setEnabled( false ); 1837 mActionConfigureToolbars->setEnabled( false );
1838#endif //KAB_EMBEDDED 1838#endif //KAB_EMBEDDED
1839 1839
1840 } else { 1840 } else {
1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1842 1842
1843 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1843 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1844 } 1844 }
1845 1845
1846 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1846 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1847 actionCollection(), "options_show_jump_bar" ); 1847 actionCollection(), "options_show_jump_bar" );
1848 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1848 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1849 1849
1850 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1850 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1851 actionCollection(), "options_show_details" ); 1851 actionCollection(), "options_show_details" );
1852 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1852 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1853 1853
1854 // misc 1854 // misc
1855 // only enable LDAP lookup if we can handle the protocol 1855 // only enable LDAP lookup if we can handle the protocol
1856#ifndef KAB_EMBEDDED 1856#ifndef KAB_EMBEDDED
1857 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1857 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1858 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1858 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1859 this, SLOT( openLDAPDialog() ), actionCollection(), 1859 this, SLOT( openLDAPDialog() ), actionCollection(),
1860 "ldap_lookup" ); 1860 "ldap_lookup" );
1861 } 1861 }
1862#else //KAB_EMBEDDED 1862#else //KAB_EMBEDDED
1863 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1863 //qDebug("KABCore::initActions() LDAP has to be implemented");
1864#endif //KAB_EMBEDDED 1864#endif //KAB_EMBEDDED
1865 1865
1866 1866
1867 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1867 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1868 SLOT( setWhoAmI() ), actionCollection(), 1868 SLOT( setWhoAmI() ), actionCollection(),
1869 "set_personal" ); 1869 "set_personal" );
1870 1870
1871 1871
1872 1872
1873 1873
1874 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1874 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1875 SLOT( setCategories() ), actionCollection(), 1875 SLOT( setCategories() ), actionCollection(),
1876 "edit_set_categories" ); 1876 "edit_set_categories" );
1877 1877
1878 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1878 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1879 SLOT( removeVoice() ), actionCollection(), 1879 SLOT( removeVoice() ), actionCollection(),
1880 "remove_voice" ); 1880 "remove_voice" );
1881 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1881 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1882 SLOT( importFromOL() ), actionCollection(), 1882 SLOT( importFromOL() ), actionCollection(),
1883 "import_OL" ); 1883 "import_OL" );
1884#ifdef KAB_EMBEDDED 1884#ifdef KAB_EMBEDDED
1885 mActionLicence = new KAction( i18n( "Licence" ), 0, 1885 mActionLicence = new KAction( i18n( "Licence" ), 0,
1886 this, SLOT( showLicence() ), actionCollection(), 1886 this, SLOT( showLicence() ), actionCollection(),
1887 "licence_about_data" ); 1887 "licence_about_data" );
1888 mActionFaq = new KAction( i18n( "Faq" ), 0, 1888 mActionFaq = new KAction( i18n( "Faq" ), 0,
1889 this, SLOT( faq() ), actionCollection(), 1889 this, SLOT( faq() ), actionCollection(),
1890 "faq_about_data" ); 1890 "faq_about_data" );
1891 1891
1892 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1892 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1893 this, SLOT( createAboutData() ), actionCollection(), 1893 this, SLOT( createAboutData() ), actionCollection(),
1894 "kaddressbook_about_data" ); 1894 "kaddressbook_about_data" );
1895#endif //KAB_EMBEDDED 1895#endif //KAB_EMBEDDED
1896 1896
1897 clipboardDataChanged(); 1897 clipboardDataChanged();
1898 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1898 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1899 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1899 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1900} 1900}
1901 1901
1902//US we need this function, to plug all actions into the correct menues. 1902//US we need this function, to plug all actions into the correct menues.
1903// KDE uses a XML format to plug the actions, but we work her without this overhead. 1903// KDE uses a XML format to plug the actions, but we work her without this overhead.
1904void KABCore::addActionsManually() 1904void KABCore::addActionsManually()
1905{ 1905{
1906//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1906//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1907 1907
1908#ifdef KAB_EMBEDDED 1908#ifdef KAB_EMBEDDED
1909 QPopupMenu *fileMenu = new QPopupMenu( this ); 1909 QPopupMenu *fileMenu = new QPopupMenu( this );
1910 QPopupMenu *editMenu = new QPopupMenu( this ); 1910 QPopupMenu *editMenu = new QPopupMenu( this );
1911 QPopupMenu *helpMenu = new QPopupMenu( this ); 1911 QPopupMenu *helpMenu = new QPopupMenu( this );
1912 1912
1913 KToolBar* tb = mMainWindow->toolBar(); 1913 KToolBar* tb = mMainWindow->toolBar();
1914 1914
1915#ifdef DESKTOP_VERSION 1915#ifdef DESKTOP_VERSION
1916 QMenuBar* mb = mMainWindow->menuBar(); 1916 QMenuBar* mb = mMainWindow->menuBar();
1917 1917
1918 //US setup menubar. 1918 //US setup menubar.
1919 //Disable the following block if you do not want to have a menubar. 1919 //Disable the following block if you do not want to have a menubar.
1920 mb->insertItem( "&File", fileMenu ); 1920 mb->insertItem( "&File", fileMenu );
1921 mb->insertItem( "&Edit", editMenu ); 1921 mb->insertItem( "&Edit", editMenu );
1922 mb->insertItem( "&View", viewMenu ); 1922 mb->insertItem( "&View", viewMenu );
1923 mb->insertItem( "&Settings", settingsMenu ); 1923 mb->insertItem( "&Settings", settingsMenu );
1924 mb->insertItem( i18n("Synchronize"), syncMenu ); 1924 mb->insertItem( i18n("Synchronize"), syncMenu );
1925 mb->insertItem( "&Change selected", changeMenu ); 1925 mb->insertItem( "&Change selected", changeMenu );
1926 mb->insertItem( "&Help", helpMenu ); 1926 mb->insertItem( "&Help", helpMenu );
1927 mIncSearchWidget = new IncSearchWidget( tb ); 1927 mIncSearchWidget = new IncSearchWidget( tb );
1928 // tb->insertWidget(-1, 0, mIncSearchWidget); 1928 // tb->insertWidget(-1, 0, mIncSearchWidget);
1929 1929
1930#else 1930#else
1931 //US setup toolbar 1931 //US setup toolbar
1932 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1932 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1933 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1933 QPopupMenu *popupBarTB = new QPopupMenu( this );
1934 menuBarTB->insertItem( "ME", popupBarTB); 1934 menuBarTB->insertItem( "ME", popupBarTB);
1935 tb->insertWidget(-1, 0, menuBarTB); 1935 tb->insertWidget(-1, 0, menuBarTB);
1936 mIncSearchWidget = new IncSearchWidget( tb ); 1936 mIncSearchWidget = new IncSearchWidget( tb );
1937 1937
1938 tb->enableMoving(false); 1938 tb->enableMoving(false);
1939 popupBarTB->insertItem( "&File", fileMenu ); 1939 popupBarTB->insertItem( "&File", fileMenu );
1940 popupBarTB->insertItem( "&Edit", editMenu ); 1940 popupBarTB->insertItem( "&Edit", editMenu );
1941 popupBarTB->insertItem( "&View", viewMenu ); 1941 popupBarTB->insertItem( "&View", viewMenu );
1942 popupBarTB->insertItem( "&Settings", settingsMenu ); 1942 popupBarTB->insertItem( "&Settings", settingsMenu );
1943 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1943 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1944 mViewManager->getFilterAction()->plug ( popupBarTB); 1944 mViewManager->getFilterAction()->plug ( popupBarTB);
1945 popupBarTB->insertItem( "&Change selected", changeMenu ); 1945 popupBarTB->insertItem( "&Change selected", changeMenu );
1946 popupBarTB->insertItem( "&Help", helpMenu ); 1946 popupBarTB->insertItem( "&Help", helpMenu );
1947 if (QApplication::desktop()->width() > 320 ) { 1947 if (QApplication::desktop()->width() > 320 ) {
1948 // mViewManager->getFilterAction()->plug ( tb); 1948 // mViewManager->getFilterAction()->plug ( tb);
1949 } 1949 }
1950#endif 1950#endif
1951 // mActionQuit->plug ( mMainWindow->toolBar()); 1951 // mActionQuit->plug ( mMainWindow->toolBar());
1952 1952
1953 1953
1954 1954
1955 //US Now connect the actions with the menue entries. 1955 //US Now connect the actions with the menue entries.
1956 mActionPrint->plug( fileMenu ); 1956 mActionPrint->plug( fileMenu );
1957 mActionMail->plug( fileMenu ); 1957 mActionMail->plug( fileMenu );
1958 fileMenu->insertSeparator(); 1958 fileMenu->insertSeparator();
1959 1959
1960 mActionNewContact->plug( fileMenu ); 1960 mActionNewContact->plug( fileMenu );
1961 mActionNewContact->plug( tb ); 1961 mActionNewContact->plug( tb );
1962 1962
1963 mActionEditAddressee->plug( fileMenu ); 1963 mActionEditAddressee->plug( fileMenu );
1964 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1964 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1965 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1965 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1966 mActionEditAddressee->plug( tb ); 1966 mActionEditAddressee->plug( tb );
1967 1967
1968 fileMenu->insertSeparator(); 1968 fileMenu->insertSeparator();
1969 mActionSave->plug( fileMenu ); 1969 mActionSave->plug( fileMenu );
1970 fileMenu->insertItem( "&Import", ImportMenu ); 1970 fileMenu->insertItem( "&Import", ImportMenu );
1971 fileMenu->insertItem( "&Export", ExportMenu ); 1971 fileMenu->insertItem( "&Export", ExportMenu );
1972 fileMenu->insertSeparator(); 1972 fileMenu->insertSeparator();
1973 mActionMailVCard->plug( fileMenu ); 1973 mActionMailVCard->plug( fileMenu );
1974#ifndef DESKTOP_VERSION 1974#ifndef DESKTOP_VERSION
1975 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1975 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1976 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1976 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1977#endif 1977#endif
1978 fileMenu->insertSeparator(); 1978 fileMenu->insertSeparator();
1979 mActionQuit->plug( fileMenu ); 1979 mActionQuit->plug( fileMenu );
1980#ifdef _WIN32_ 1980#ifdef _WIN32_
1981 mActionImportOL->plug( ImportMenu ); 1981 mActionImportOL->plug( ImportMenu );
1982#endif 1982#endif
1983 // edit menu 1983 // edit menu
1984 mActionUndo->plug( editMenu ); 1984 mActionUndo->plug( editMenu );
1985 mActionRedo->plug( editMenu ); 1985 mActionRedo->plug( editMenu );
1986 editMenu->insertSeparator(); 1986 editMenu->insertSeparator();
1987 mActionCut->plug( editMenu ); 1987 mActionCut->plug( editMenu );
1988 mActionCopy->plug( editMenu ); 1988 mActionCopy->plug( editMenu );
1989 mActionPaste->plug( editMenu ); 1989 mActionPaste->plug( editMenu );
1990 mActionDelete->plug( editMenu ); 1990 mActionDelete->plug( editMenu );
1991 editMenu->insertSeparator(); 1991 editMenu->insertSeparator();
1992 mActionSelectAll->plug( editMenu ); 1992 mActionSelectAll->plug( editMenu );
1993 1993
1994 mActionRemoveVoice->plug( changeMenu ); 1994 mActionRemoveVoice->plug( changeMenu );
1995 // settings menu 1995 // settings menu
1996//US special menuentry to configure the addressbook resources. On KDE 1996//US special menuentry to configure the addressbook resources. On KDE
1997// you do that through the control center !!! 1997// you do that through the control center !!!
1998 mActionConfigResources->plug( settingsMenu ); 1998 mActionConfigResources->plug( settingsMenu );
1999 settingsMenu->insertSeparator(); 1999 settingsMenu->insertSeparator();
2000 2000
2001 mActionConfigKAddressbook->plug( settingsMenu ); 2001 mActionConfigKAddressbook->plug( settingsMenu );
2002 2002
2003 if ( mIsPart ) { 2003 if ( mIsPart ) {
2004 mActionConfigShortcuts->plug( settingsMenu ); 2004 mActionConfigShortcuts->plug( settingsMenu );
2005 mActionConfigureToolbars->plug( settingsMenu ); 2005 mActionConfigureToolbars->plug( settingsMenu );
2006 2006
2007 } else { 2007 } else {
2008 mActionKeyBindings->plug( settingsMenu ); 2008 mActionKeyBindings->plug( settingsMenu );
2009 } 2009 }
2010 2010
2011 settingsMenu->insertSeparator(); 2011 settingsMenu->insertSeparator();
2012 2012
2013 mActionJumpBar->plug( settingsMenu ); 2013 mActionJumpBar->plug( settingsMenu );
2014 mActionDetails->plug( settingsMenu ); 2014 mActionDetails->plug( settingsMenu );
2015 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2015 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2016 mActionDetails->plug( tb ); 2016 mActionDetails->plug( tb );
2017 settingsMenu->insertSeparator(); 2017 settingsMenu->insertSeparator();
2018 2018
2019 mActionWhoAmI->plug( settingsMenu ); 2019 mActionWhoAmI->plug( settingsMenu );
2020 mActionCategories->plug( settingsMenu ); 2020 mActionCategories->plug( settingsMenu );
2021 2021
2022 mActionLicence->plug( helpMenu ); 2022 mActionLicence->plug( helpMenu );
2023 mActionFaq->plug( helpMenu ); 2023 mActionFaq->plug( helpMenu );
2024 mActionAboutKAddressbook->plug( helpMenu ); 2024 mActionAboutKAddressbook->plug( helpMenu );
2025 2025
2026 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2026 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2027 2027
2028 mActionSave->plug( tb ); 2028 mActionSave->plug( tb );
2029 mViewManager->getFilterAction()->plug ( tb); 2029 mViewManager->getFilterAction()->plug ( tb);
2030 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2030 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2031 mActionUndo->plug( tb ); 2031 mActionUndo->plug( tb );
2032 mActionDelete->plug( tb ); 2032 mActionDelete->plug( tb );
2033 mActionRedo->plug( tb ); 2033 mActionRedo->plug( tb );
2034 } 2034 }
2035 } 2035 }
2036 //mActionQuit->plug ( tb ); 2036 //mActionQuit->plug ( tb );
2037 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2037 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2038 2038
2039 //US link the searchwidget first to this. 2039 //US link the searchwidget first to this.
2040 // The real linkage to the toolbar happens later. 2040 // The real linkage to the toolbar happens later.
2041//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2041//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2042//US tb->insertItem( mIncSearchWidget ); 2042//US tb->insertItem( mIncSearchWidget );
2043/*US 2043/*US
2044 mIncSearchWidget = new IncSearchWidget( tb ); 2044 mIncSearchWidget = new IncSearchWidget( tb );
2045 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2045 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2046 SLOT( incrementalSearch( const QString& ) ) ); 2046 SLOT( incrementalSearch( const QString& ) ) );
2047 2047
2048 mJumpButtonBar = new JumpButtonBar( this, this ); 2048 mJumpButtonBar = new JumpButtonBar( this, this );
2049 2049
2050//US topLayout->addWidget( mJumpButtonBar ); 2050//US topLayout->addWidget( mJumpButtonBar );
2051 this->layout()->add( mJumpButtonBar ); 2051 this->layout()->add( mJumpButtonBar );
2052*/ 2052*/
2053 2053
2054#endif //KAB_EMBEDDED 2054#endif //KAB_EMBEDDED
2055 2055
2056 mActionExport2phone->plug( ExportMenu ); 2056 mActionExport2phone->plug( ExportMenu );
2057 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2057 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2058 syncManager->fillSyncMenu(); 2058 syncManager->fillSyncMenu();
2059 2059
2060} 2060}
2061void KABCore::showLicence() 2061void KABCore::showLicence()
2062{ 2062{
2063 KApplication::showLicence(); 2063 KApplication::showLicence();
2064} 2064}
2065void KABCore::removeVoice() 2065void KABCore::removeVoice()
2066{ 2066{
2067 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2067 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2068 return; 2068 return;
2069 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2069 KABC::Addressee::List list = mViewManager->selectedAddressees();
2070 KABC::Addressee::List::Iterator it; 2070 KABC::Addressee::List::Iterator it;
2071 for ( it = list.begin(); it != list.end(); ++it ) { 2071 for ( it = list.begin(); it != list.end(); ++it ) {
2072 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 2072 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
2073 PhoneNumber::List::Iterator phoneIt; 2073 PhoneNumber::List::Iterator phoneIt;
2074 bool found = false; 2074 bool found = false;
2075 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 2075 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
2076 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 2076 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
2077 if ((*phoneIt).type() - PhoneNumber::Voice ) { 2077 if ((*phoneIt).type() - PhoneNumber::Voice ) {
2078 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 2078 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
2079 (*it).insertPhoneNumber( (*phoneIt) ); 2079 (*it).insertPhoneNumber( (*phoneIt) );
2080 found = true; 2080 found = true;
2081 } 2081 }
2082 } 2082 }
2083 2083
2084 } 2084 }
2085 if ( found ) 2085 if ( found )
2086 contactModified((*it) ); 2086 contactModified((*it) );
2087 } 2087 }
2088} 2088}
2089 2089
2090 2090
2091 2091
2092void KABCore::clipboardDataChanged() 2092void KABCore::clipboardDataChanged()
2093{ 2093{
2094 2094
2095 if ( mReadWrite ) 2095 if ( mReadWrite )
2096 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2096 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2097 2097
2098} 2098}
2099 2099
2100void KABCore::updateActionMenu() 2100void KABCore::updateActionMenu()
2101{ 2101{
2102 UndoStack *undo = UndoStack::instance(); 2102 UndoStack *undo = UndoStack::instance();
2103 RedoStack *redo = RedoStack::instance(); 2103 RedoStack *redo = RedoStack::instance();
2104 2104
2105 if ( undo->isEmpty() ) 2105 if ( undo->isEmpty() )
2106 mActionUndo->setText( i18n( "Undo" ) ); 2106 mActionUndo->setText( i18n( "Undo" ) );
2107 else 2107 else
2108 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2108 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2109 2109
2110 mActionUndo->setEnabled( !undo->isEmpty() ); 2110 mActionUndo->setEnabled( !undo->isEmpty() );
2111 2111
2112 if ( !redo->top() ) 2112 if ( !redo->top() )
2113 mActionRedo->setText( i18n( "Redo" ) ); 2113 mActionRedo->setText( i18n( "Redo" ) );
2114 else 2114 else
2115 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2115 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2116 2116
2117 mActionRedo->setEnabled( !redo->isEmpty() ); 2117 mActionRedo->setEnabled( !redo->isEmpty() );
2118} 2118}
2119 2119
2120void KABCore::configureKeyBindings() 2120void KABCore::configureKeyBindings()
2121{ 2121{
2122#ifndef KAB_EMBEDDED 2122#ifndef KAB_EMBEDDED
2123 KKeyDialog::configure( actionCollection(), true ); 2123 KKeyDialog::configure( actionCollection(), true );
2124#else //KAB_EMBEDDED 2124#else //KAB_EMBEDDED
2125 qDebug("KABCore::configureKeyBindings() not implemented"); 2125 qDebug("KABCore::configureKeyBindings() not implemented");
2126#endif //KAB_EMBEDDED 2126#endif //KAB_EMBEDDED
2127} 2127}
2128 2128
2129#ifdef KAB_EMBEDDED 2129#ifdef KAB_EMBEDDED
2130void KABCore::configureResources() 2130void KABCore::configureResources()
2131{ 2131{
2132 KRES::KCMKResources dlg( this, "" , 0 ); 2132 KRES::KCMKResources dlg( this, "" , 0 );
2133 2133
2134 if ( !dlg.exec() ) 2134 if ( !dlg.exec() )
2135 return; 2135 return;
2136 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2136 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2137} 2137}
2138#endif //KAB_EMBEDDED 2138#endif //KAB_EMBEDDED
2139 2139
2140 2140
2141/* this method will be called through the QCop interface from Ko/Pi to select addresses 2141/* this method will be called through the QCop interface from Ko/Pi to select addresses
2142 * for the attendees list of an event. 2142 * for the attendees list of an event.
2143 */ 2143 */
2144void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2144void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2145{ 2145{
2146 QStringList nameList; 2146 QStringList nameList;
2147 QStringList emailList; 2147 QStringList emailList;
2148 QStringList uidList; 2148 QStringList uidList;
2149 2149
2150 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2150 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2151 uint i=0; 2151 uint i=0;
2152 for (i=0; i < list.count(); i++) 2152 for (i=0; i < list.count(); i++)
2153 { 2153 {
2154 nameList.append(list[i].realName()); 2154 nameList.append(list[i].realName());
2155 emailList.append(list[i].preferredEmail()); 2155 emailList.append(list[i].preferredEmail());
2156 uidList.append(list[i].uid()); 2156 uidList.append(list[i].uid());
2157 } 2157 }
2158 2158
2159 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2159 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2160 2160
2161} 2161}
2162 2162
2163/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2163/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2164 * to put them into the calendar. 2164 * to put them into the calendar.
2165 */ 2165 */
2166void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2166void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2167{ 2167{
2168 // qDebug("KABCore::requestForBirthdayList"); 2168 // qDebug("KABCore::requestForBirthdayList");
2169 QStringList birthdayList; 2169 QStringList birthdayList;
2170 QStringList anniversaryList; 2170 QStringList anniversaryList;
2171 QStringList realNameList; 2171 QStringList realNameList;
2172 QStringList preferredEmailList; 2172 QStringList preferredEmailList;
2173 QStringList assembledNameList; 2173 QStringList assembledNameList;
2174 QStringList uidList; 2174 QStringList uidList;
2175 2175
2176 KABC::AddressBook::Iterator it; 2176 KABC::AddressBook::Iterator it;
2177 2177
2178 int count = 0; 2178 int count = 0;
2179 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2179 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2180 ++count; 2180 ++count;
2181 } 2181 }
2182 QProgressBar bar(count,0 ); 2182 QProgressBar bar(count,0 );
2183 int w = 300; 2183 int w = 300;
2184 if ( QApplication::desktop()->width() < 320 ) 2184 if ( QApplication::desktop()->width() < 320 )
2185 w = 220; 2185 w = 220;
2186 int h = bar.sizeHint().height() ; 2186 int h = bar.sizeHint().height() ;
2187 int dw = QApplication::desktop()->width(); 2187 int dw = QApplication::desktop()->width();
2188 int dh = QApplication::desktop()->height(); 2188 int dh = QApplication::desktop()->height();
2189 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2189 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2190 bar.show(); 2190 bar.show();
2191 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2191 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2192 qApp->processEvents(); 2192 qApp->processEvents();
2193 2193
2194 QDate bday; 2194 QDate bday;
2195 QString anni; 2195 QString anni;
2196 QString formattedbday; 2196 QString formattedbday;
2197 2197
2198 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2198 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2199 { 2199 {
2200 if ( ! bar.isVisible() ) 2200 if ( ! bar.isVisible() )
2201 return; 2201 return;
2202 bar.setProgress( count++ ); 2202 bar.setProgress( count++ );
2203 qApp->processEvents(); 2203 qApp->processEvents();
2204 bday = (*it).birthday().date(); 2204 bday = (*it).birthday().date();
2205 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2205 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2206 2206
2207 if ( bday.isValid() || !anni.isEmpty()) 2207 if ( bday.isValid() || !anni.isEmpty())
2208 { 2208 {
2209 if (bday.isValid()) 2209 if (bday.isValid())
2210 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2210 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2211 else 2211 else
2212 formattedbday = "NOTVALID"; 2212 formattedbday = "NOTVALID";
2213 if (anni.isEmpty()) 2213 if (anni.isEmpty())
2214 anni = "INVALID"; 2214 anni = "INVALID";
2215 2215
2216 birthdayList.append(formattedbday); 2216 birthdayList.append(formattedbday);
2217 anniversaryList.append(anni); //should be ISODate 2217 anniversaryList.append(anni); //should be ISODate
2218 realNameList.append((*it).realName()); 2218 realNameList.append((*it).realName());
2219 preferredEmailList.append((*it).preferredEmail()); 2219 preferredEmailList.append((*it).preferredEmail());
2220 assembledNameList.append((*it).assembledName()); 2220 assembledNameList.append((*it).assembledName());
2221 uidList.append((*it).uid()); 2221 uidList.append((*it).uid());
2222 2222
2223 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2223 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2224 } 2224 }
2225 } 2225 }
2226 2226
2227 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2227 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2228 2228
2229} 2229}
2230 2230
2231/* this method will be called through the QCop interface from other apps to show details of a contact. 2231/* this method will be called through the QCop interface from other apps to show details of a contact.
2232 */ 2232 */
2233void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2233void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2234{ 2234{
2235 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2235 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2236 2236
2237 QString foundUid = QString::null; 2237 QString foundUid = QString::null;
2238 if ( ! uid.isEmpty() ) { 2238 if ( ! uid.isEmpty() ) {
2239 Addressee adrr = mAddressBook->findByUid( uid ); 2239 Addressee adrr = mAddressBook->findByUid( uid );
2240 if ( !adrr.isEmpty() ) { 2240 if ( !adrr.isEmpty() ) {
2241 foundUid = uid; 2241 foundUid = uid;
2242 } 2242 }
2243 if ( email == "sendbacklist" ) { 2243 if ( email == "sendbacklist" ) {
2244 //qDebug("ssssssssssssssssssssssend "); 2244 //qDebug("ssssssssssssssssssssssend ");
2245 QStringList nameList; 2245 QStringList nameList;
2246 QStringList emailList; 2246 QStringList emailList;
2247 QStringList uidList; 2247 QStringList uidList;
2248 nameList.append(adrr.realName()); 2248 nameList.append(adrr.realName());
2249 emailList = adrr.emails(); 2249 emailList = adrr.emails();
2250 uidList.append( adrr.preferredEmail()); 2250 uidList.append( adrr.preferredEmail());
2251 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2251 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2252 return; 2252 return;
2253 } 2253 }
2254 2254
2255 } 2255 }
2256 2256
2257 if ( email == "sendbacklist" ) 2257 if ( email == "sendbacklist" )
2258 return; 2258 return;
2259 if (foundUid.isEmpty()) 2259 if (foundUid.isEmpty())
2260 { 2260 {
2261 //find the uid of the person first 2261 //find the uid of the person first
2262 Addressee::List namelist; 2262 Addressee::List namelist;
2263 Addressee::List emaillist; 2263 Addressee::List emaillist;
2264 2264
2265 if (!name.isEmpty()) 2265 if (!name.isEmpty())
2266 namelist = mAddressBook->findByName( name ); 2266 namelist = mAddressBook->findByName( name );
2267 2267
2268 if (!email.isEmpty()) 2268 if (!email.isEmpty())
2269 emaillist = mAddressBook->findByEmail( email ); 2269 emaillist = mAddressBook->findByEmail( email );
2270 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2270 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2271 //check if we have a match in Namelist and Emaillist 2271 //check if we have a match in Namelist and Emaillist
2272 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2272 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2273 foundUid = emaillist[0].uid(); 2273 foundUid = emaillist[0].uid();
2274 } 2274 }
2275 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2275 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2276 foundUid = namelist[0].uid(); 2276 foundUid = namelist[0].uid();
2277 else 2277 else
2278 { 2278 {
2279 for (int i = 0; i < namelist.count(); i++) 2279 for (int i = 0; i < namelist.count(); i++)
2280 { 2280 {
2281 for (int j = 0; j < emaillist.count(); j++) 2281 for (int j = 0; j < emaillist.count(); j++)
2282 { 2282 {
2283 if (namelist[i] == emaillist[j]) 2283 if (namelist[i] == emaillist[j])
2284 { 2284 {
2285 foundUid = namelist[i].uid(); 2285 foundUid = namelist[i].uid();
2286 } 2286 }
2287 } 2287 }
2288 } 2288 }
2289 } 2289 }
2290 } 2290 }
2291 else 2291 else
2292 { 2292 {
2293 foundUid = uid; 2293 foundUid = uid;
2294 } 2294 }
2295 2295
2296 if (!foundUid.isEmpty()) 2296 if (!foundUid.isEmpty())
2297 { 2297 {
2298 2298
2299 // raise Ka/Pi if it is in the background 2299 // raise Ka/Pi if it is in the background
2300#ifndef DESKTOP_VERSION 2300#ifndef DESKTOP_VERSION
2301#ifndef KORG_NODCOP 2301#ifndef KORG_NODCOP
2302 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2302 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2303#endif 2303#endif
2304#endif 2304#endif
2305 2305
2306 mMainWindow->showMaximized(); 2306 mMainWindow->showMaximized();
2307 mMainWindow-> raise(); 2307 mMainWindow-> raise();
2308 2308
2309 mViewManager->setSelected( "", false); 2309 mViewManager->setSelected( "", false);
2310 mViewManager->refreshView( "" ); 2310 mViewManager->refreshView( "" );
2311 mViewManager->setSelected( foundUid, true ); 2311 mViewManager->setSelected( foundUid, true );
2312 mViewManager->refreshView( foundUid ); 2312 mViewManager->refreshView( foundUid );
2313 2313
2314 if ( !mMultipleViewsAtOnce ) 2314 if ( !mMultipleViewsAtOnce )
2315 { 2315 {
2316 setDetailsVisible( true ); 2316 setDetailsVisible( true );
2317 mActionDetails->setChecked(true); 2317 mActionDetails->setChecked(true);
2318 } 2318 }
2319 } 2319 }
2320} 2320}
2321 2321
2322 2322
2323void KABCore::faq() 2323void KABCore::faq()
2324{ 2324{
2325 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2325 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2326} 2326}
2327 2327
2328#include <libkcal/syncdefines.h> 2328#include <libkcal/syncdefines.h>
2329 2329
2330KABC::Addressee KABCore::getLastSyncAddressee() 2330KABC::Addressee KABCore::getLastSyncAddressee()
2331{ 2331{
2332 Addressee lse; 2332 Addressee lse;
2333 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2333 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2334 2334
2335 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2335 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2336 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2336 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2337 if (lse.isEmpty()) { 2337 if (lse.isEmpty()) {
2338 qDebug("Creating new last-syncAddressee "); 2338 qDebug("Creating new last-syncAddressee ");
2339 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2339 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2340 QString sum = ""; 2340 QString sum = "";
2341 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2341 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2342 sum = "E: "; 2342 sum = "E: ";
2343 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2343 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2344 lse.setRevision( mLastAddressbookSync ); 2344 lse.setRevision( mLastAddressbookSync );
2345 lse.setCategories( i18n("SyncEvent") ); 2345 lse.setCategories( i18n("SyncEvent") );
2346 mAddressBook->insertAddressee( lse ); 2346 mAddressBook->insertAddressee( lse );
2347 } 2347 }
2348 return lse; 2348 return lse;
2349} 2349}
2350int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2350int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2351{ 2351{
2352 2352
2353 //void setZaurusId(int id); 2353 //void setZaurusId(int id);
2354 // int zaurusId() const; 2354 // int zaurusId() const;
2355 // void setZaurusUid(int id); 2355 // void setZaurusUid(int id);
2356 // int zaurusUid() const; 2356 // int zaurusUid() const;
2357 // void setZaurusStat(int id); 2357 // void setZaurusStat(int id);
2358 // int zaurusStat() const; 2358 // int zaurusStat() const;
2359 // 0 equal 2359 // 0 equal
2360 // 1 take local 2360 // 1 take local
2361 // 2 take remote 2361 // 2 take remote
2362 // 3 cancel 2362 // 3 cancel
2363 QDateTime lastSync = mLastAddressbookSync; 2363 QDateTime lastSync = mLastAddressbookSync;
2364 QDateTime localMod = local->revision(); 2364 QDateTime localMod = local->revision();
2365 QDateTime remoteMod = remote->revision(); 2365 QDateTime remoteMod = remote->revision();
2366 2366
2367 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2367 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2368 2368
2369 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2369 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2370 bool remCh, locCh; 2370 bool remCh, locCh;
2371 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2371 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2372 2372
2373 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2373 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2374 locCh = ( localMod > mLastAddressbookSync ); 2374 locCh = ( localMod > mLastAddressbookSync );
2375 if ( !remCh && ! locCh ) { 2375 if ( !remCh && ! locCh ) {
2376 //qDebug("both not changed "); 2376 //qDebug("both not changed ");
2377 lastSync = localMod.addDays(1); 2377 lastSync = localMod.addDays(1);
2378 if ( mode <= SYNC_PREF_ASK ) 2378 if ( mode <= SYNC_PREF_ASK )
2379 return 0; 2379 return 0;
2380 } else { 2380 } else {
2381 if ( locCh ) { 2381 if ( locCh ) {
2382 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2382 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2383 lastSync = localMod.addDays( -1 ); 2383 lastSync = localMod.addDays( -1 );
2384 if ( !remCh ) 2384 if ( !remCh )
2385 remoteMod =( lastSync.addDays( -1 ) ); 2385 remoteMod =( lastSync.addDays( -1 ) );
2386 } else { 2386 } else {
2387 //qDebug(" not loc changed "); 2387 //qDebug(" not loc changed ");
2388 lastSync = localMod.addDays( 1 ); 2388 lastSync = localMod.addDays( 1 );
2389 if ( remCh ) 2389 if ( remCh )
2390 remoteMod =( lastSync.addDays( 1 ) ); 2390 remoteMod =( lastSync.addDays( 1 ) );
2391 2391
2392 } 2392 }
2393 } 2393 }
2394 full = true; 2394 full = true;
2395 if ( mode < SYNC_PREF_ASK ) 2395 if ( mode < SYNC_PREF_ASK )
2396 mode = SYNC_PREF_ASK; 2396 mode = SYNC_PREF_ASK;
2397 } else { 2397 } else {
2398 if ( localMod == remoteMod ) 2398 if ( localMod == remoteMod )
2399 return 0; 2399 return 0;
2400 2400
2401 } 2401 }
2402 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2402 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2403 2403
2404 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2404 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2405 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2405 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2406 //full = true; //debug only 2406 //full = true; //debug only
2407 if ( full ) { 2407 if ( full ) {
2408 bool equ = ( (*local) == (*remote) ); 2408 bool equ = ( (*local) == (*remote) );
2409 if ( equ ) { 2409 if ( equ ) {
2410 //qDebug("equal "); 2410 //qDebug("equal ");
2411 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2411 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2412 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2412 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2413 } 2413 }
2414 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2414 if ( mode < SYNC_PREF_FORCE_LOCAL )
2415 return 0; 2415 return 0;
2416 2416
2417 }//else //debug only 2417 }//else //debug only
2418 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2418 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2419 } 2419 }
2420 int result; 2420 int result;
2421 bool localIsNew; 2421 bool localIsNew;
2422 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2422 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2423 2423
2424 if ( full && mode < SYNC_PREF_NEWEST ) 2424 if ( full && mode < SYNC_PREF_NEWEST )
2425 mode = SYNC_PREF_ASK; 2425 mode = SYNC_PREF_ASK;
2426 2426
2427 switch( mode ) { 2427 switch( mode ) {
2428 case SYNC_PREF_LOCAL: 2428 case SYNC_PREF_LOCAL:
2429 if ( lastSync > remoteMod ) 2429 if ( lastSync > remoteMod )
2430 return 1; 2430 return 1;
2431 if ( lastSync > localMod ) 2431 if ( lastSync > localMod )
2432 return 2; 2432 return 2;
2433 return 1; 2433 return 1;
2434 break; 2434 break;
2435 case SYNC_PREF_REMOTE: 2435 case SYNC_PREF_REMOTE:
2436 if ( lastSync > remoteMod ) 2436 if ( lastSync > remoteMod )
2437 return 1; 2437 return 1;
2438 if ( lastSync > localMod ) 2438 if ( lastSync > localMod )
2439 return 2; 2439 return 2;
2440 return 2; 2440 return 2;
2441 break; 2441 break;
2442 case SYNC_PREF_NEWEST: 2442 case SYNC_PREF_NEWEST:
2443 if ( localMod > remoteMod ) 2443 if ( localMod > remoteMod )
2444 return 1; 2444 return 1;
2445 else 2445 else
2446 return 2; 2446 return 2;
2447 break; 2447 break;
2448 case SYNC_PREF_ASK: 2448 case SYNC_PREF_ASK:
2449 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2449 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2450 if ( lastSync > remoteMod ) 2450 if ( lastSync > remoteMod )
2451 return 1; 2451 return 1;
2452 if ( lastSync > localMod ) 2452 if ( lastSync > localMod )
2453 return 2; 2453 return 2;
2454 localIsNew = localMod >= remoteMod; 2454 localIsNew = localMod >= remoteMod;
2455 //qDebug("conflict! ************************************** "); 2455 //qDebug("conflict! ************************************** ");
2456 { 2456 {
2457 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2457 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2458 result = acd.executeD(localIsNew); 2458 result = acd.executeD(localIsNew);
2459 return result; 2459 return result;
2460 } 2460 }
2461 break; 2461 break;
2462 case SYNC_PREF_FORCE_LOCAL: 2462 case SYNC_PREF_FORCE_LOCAL:
2463 return 1; 2463 return 1;
2464 break; 2464 break;
2465 case SYNC_PREF_FORCE_REMOTE: 2465 case SYNC_PREF_FORCE_REMOTE:
2466 return 2; 2466 return 2;
2467 break; 2467 break;
2468 2468
2469 default: 2469 default:
2470 // SYNC_PREF_TAKE_BOTH not implemented 2470 // SYNC_PREF_TAKE_BOTH not implemented
2471 break; 2471 break;
2472 } 2472 }
2473 return 0; 2473 return 0;
2474} 2474}
2475 2475
2476 2476
2477bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2477bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2478{ 2478{
2479 bool syncOK = true; 2479 bool syncOK = true;
2480 int addedAddressee = 0; 2480 int addedAddressee = 0;
2481 int addedAddresseeR = 0; 2481 int addedAddresseeR = 0;
2482 int deletedAddresseeR = 0; 2482 int deletedAddresseeR = 0;
2483 int deletedAddresseeL = 0; 2483 int deletedAddresseeL = 0;
2484 int changedLocal = 0; 2484 int changedLocal = 0;
2485 int changedRemote = 0; 2485 int changedRemote = 0;
2486 2486
2487 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2487 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2488 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2488 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2489 2489
2490 //QPtrList<Addressee> el = local->rawAddressees(); 2490 //QPtrList<Addressee> el = local->rawAddressees();
2491 Addressee addresseeR; 2491 Addressee addresseeR;
2492 QString uid; 2492 QString uid;
2493 int take; 2493 int take;
2494 Addressee addresseeL; 2494 Addressee addresseeL;
2495 Addressee addresseeRSync; 2495 Addressee addresseeRSync;
2496 Addressee addresseeLSync; 2496 Addressee addresseeLSync;
2497 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2497 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2498 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2498 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2499 bool fullDateRange = false; 2499 bool fullDateRange = false;
2500 local->resetTempSyncStat(); 2500 local->resetTempSyncStat();
2501 mLastAddressbookSync = QDateTime::currentDateTime(); 2501 mLastAddressbookSync = QDateTime::currentDateTime();
2502 QDateTime modifiedCalendar = mLastAddressbookSync;; 2502 QDateTime modifiedCalendar = mLastAddressbookSync;;
2503 addresseeLSync = getLastSyncAddressee(); 2503 addresseeLSync = getLastSyncAddressee();
2504 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2504 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2505 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2505 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2506 if ( !addresseeR.isEmpty() ) { 2506 if ( !addresseeR.isEmpty() ) {
2507 addresseeRSync = addresseeR; 2507 addresseeRSync = addresseeR;
2508 remote->removeAddressee(addresseeR ); 2508 remote->removeAddressee(addresseeR );
2509 2509
2510 } else { 2510 } else {
2511 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2511 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2512 addresseeRSync = addresseeLSync ; 2512 addresseeRSync = addresseeLSync ;
2513 } else { 2513 } else {
2514 qDebug("FULLDATE 1"); 2514 qDebug("FULLDATE 1");
2515 fullDateRange = true; 2515 fullDateRange = true;
2516 Addressee newAdd; 2516 Addressee newAdd;
2517 addresseeRSync = newAdd; 2517 addresseeRSync = newAdd;
2518 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2518 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2519 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2519 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2520 addresseeRSync.setRevision( mLastAddressbookSync ); 2520 addresseeRSync.setRevision( mLastAddressbookSync );
2521 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2521 addresseeRSync.setCategories( i18n("SyncAddressee") );
2522 } 2522 }
2523 } 2523 }
2524 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2524 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2525 qDebug("FULLDATE 2"); 2525 qDebug("FULLDATE 2");
2526 fullDateRange = true; 2526 fullDateRange = true;
2527 } 2527 }
2528 if ( ! fullDateRange ) { 2528 if ( ! fullDateRange ) {
2529 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2529 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2530 2530
2531 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2531 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2532 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2532 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2533 fullDateRange = true; 2533 fullDateRange = true;
2534 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2534 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2535 } 2535 }
2536 } 2536 }
2537 // fullDateRange = true; // debug only! 2537 // fullDateRange = true; // debug only!
2538 if ( fullDateRange ) 2538 if ( fullDateRange )
2539 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2539 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2540 else 2540 else
2541 mLastAddressbookSync = addresseeLSync.revision(); 2541 mLastAddressbookSync = addresseeLSync.revision();
2542 // for resyncing if own file has changed 2542 // for resyncing if own file has changed
2543 // PENDING fixme later when implemented 2543 // PENDING fixme later when implemented
2544#if 0 2544#if 0
2545 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2545 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2546 mLastAddressbookSync = loadedFileVersion; 2546 mLastAddressbookSync = loadedFileVersion;
2547 qDebug("setting mLastAddressbookSync "); 2547 qDebug("setting mLastAddressbookSync ");
2548 } 2548 }
2549#endif 2549#endif
2550 2550
2551 //qDebug("*************************** "); 2551 //qDebug("*************************** ");
2552 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2552 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2553 QStringList er = remote->uidList(); 2553 QStringList er = remote->uidList();
2554 Addressee inR ;//= er.first(); 2554 Addressee inR ;//= er.first();
2555 Addressee inL; 2555 Addressee inL;
2556 2556
2557 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2557 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2558 2558
2559 int modulo = (er.count()/10)+1; 2559 int modulo = (er.count()/10)+1;
2560 int incCounter = 0; 2560 int incCounter = 0;
2561 while ( incCounter < er.count()) { 2561 while ( incCounter < er.count()) {
2562 if (syncManager->isProgressBarCanceled()) 2562 if (syncManager->isProgressBarCanceled())
2563 return false; 2563 return false;
2564 if ( incCounter % modulo == 0 ) 2564 if ( incCounter % modulo == 0 )
2565 syncManager->showProgressBar(incCounter); 2565 syncManager->showProgressBar(incCounter);
2566 2566
2567 uid = er[ incCounter ]; 2567 uid = er[ incCounter ];
2568 bool skipIncidence = false; 2568 bool skipIncidence = false;
2569 if ( uid.left(19) == QString("last-syncAddressee-") ) 2569 if ( uid.left(19) == QString("last-syncAddressee-") )
2570 skipIncidence = true; 2570 skipIncidence = true;
2571 QString idS,OidS; 2571 QString idS,OidS;
2572 qApp->processEvents(); 2572 qApp->processEvents();
2573 if ( !skipIncidence ) { 2573 if ( !skipIncidence ) {
2574 inL = local->findByUid( uid ); 2574 inL = local->findByUid( uid );
2575 inR = remote->findByUid( uid ); 2575 inR = remote->findByUid( uid );
2576 //inL.setResource( 0 ); 2576 //inL.setResource( 0 );
2577 //inR.setResource( 0 ); 2577 //inR.setResource( 0 );
2578 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2578 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2579 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2579 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2580 //qDebug("take %d %s ", take, inL.summary().latin1()); 2580 //qDebug("take %d %s ", take, inL.summary().latin1());
2581 if ( take == 3 ) 2581 if ( take == 3 )
2582 return false; 2582 return false;
2583 if ( take == 1 ) {// take local 2583 if ( take == 1 ) {// take local
2584 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2584 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2585 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2585 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2586 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2586 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2587 local->insertAddressee( inL, false ); 2587 local->insertAddressee( inL, false );
2588 idS = inR.externalUID(); 2588 idS = inR.externalUID();
2589 OidS = inR.originalExternalUID(); 2589 OidS = inR.originalExternalUID();
2590 } 2590 }
2591 else 2591 else
2592 idS = inR.IDStr(); 2592 idS = inR.IDStr();
2593 remote->removeAddressee( inR ); 2593 remote->removeAddressee( inR );
2594 inR = inL; 2594 inR = inL;
2595 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2595 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2597 inR.setOriginalExternalUID( OidS ); 2597 inR.setOriginalExternalUID( OidS );
2598 inR.setExternalUID( idS ); 2598 inR.setExternalUID( idS );
2599 } else { 2599 } else {
2600 inR.setIDStr( idS ); 2600 inR.setIDStr( idS );
2601 } 2601 }
2602 inR.setResource( 0 ); 2602 inR.setResource( 0 );
2603 remote->insertAddressee( inR , false); 2603 remote->insertAddressee( inR , false);
2604 ++changedRemote; 2604 ++changedRemote;
2605 } else { // take == 2 take remote 2605 } else { // take == 2 take remote
2606 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2606 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2607 if ( inR.revision().date().year() < 2004 ) 2607 if ( inR.revision().date().year() < 2004 )
2608 inR.setRevision( modifiedCalendar ); 2608 inR.setRevision( modifiedCalendar );
2609 } 2609 }
2610 idS = inL.IDStr(); 2610 idS = inL.IDStr();
2611 local->removeAddressee( inL ); 2611 local->removeAddressee( inL );
2612 inL = inR; 2612 inL = inR;
2613 inL.setIDStr( idS ); 2613 inL.setIDStr( idS );
2614 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2614 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2615 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2615 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2616 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2616 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2617 } 2617 }
2618 inL.setResource( 0 ); 2618 inL.setResource( 0 );
2619 local->insertAddressee( inL , false ); 2619 local->insertAddressee( inL , false );
2620 ++changedLocal; 2620 ++changedLocal;
2621 } 2621 }
2622 } 2622 }
2623 } else { // no conflict 2623 } else { // no conflict
2624 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2624 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2625 QString des = addresseeLSync.note(); 2625 QString des = addresseeLSync.note();
2626 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2626 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2627 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2627 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2628 remote->insertAddressee( inR, false ); 2628 remote->insertAddressee( inR, false );
2629 ++deletedAddresseeR; 2629 ++deletedAddresseeR;
2630 } else { 2630 } else {
2631 inR.setRevision( modifiedCalendar ); 2631 inR.setRevision( modifiedCalendar );
2632 remote->insertAddressee( inR, false ); 2632 remote->insertAddressee( inR, false );
2633 inL = inR; 2633 inL = inR;
2634 inL.setResource( 0 ); 2634 inL.setResource( 0 );
2635 local->insertAddressee( inL , false); 2635 local->insertAddressee( inL , false);
2636 ++addedAddressee; 2636 ++addedAddressee;
2637 } 2637 }
2638 } else { 2638 } else {
2639 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2639 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2640 inR.setRevision( modifiedCalendar ); 2640 inR.setRevision( modifiedCalendar );
2641 remote->insertAddressee( inR, false ); 2641 remote->insertAddressee( inR, false );
2642 inR.setResource( 0 ); 2642 inR.setResource( 0 );
2643 local->insertAddressee( inR, false ); 2643 local->insertAddressee( inR, false );
2644 ++addedAddressee; 2644 ++addedAddressee;
2645 } else { 2645 } else {
2646 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2646 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2647 remote->removeAddressee( inR ); 2647 remote->removeAddressee( inR );
2648 ++deletedAddresseeR; 2648 ++deletedAddresseeR;
2649 } 2649 }
2650 } 2650 }
2651 } 2651 }
2652 } 2652 }
2653 ++incCounter; 2653 ++incCounter;
2654 } 2654 }
2655 er.clear(); 2655 er.clear();
2656 QStringList el = local->uidList(); 2656 QStringList el = local->uidList();
2657 modulo = (el.count()/10)+1; 2657 modulo = (el.count()/10)+1;
2658 2658
2659 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2659 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2660 incCounter = 0; 2660 incCounter = 0;
2661 while ( incCounter < el.count()) { 2661 while ( incCounter < el.count()) {
2662 qApp->processEvents(); 2662 qApp->processEvents();
2663 if (syncManager->isProgressBarCanceled()) 2663 if (syncManager->isProgressBarCanceled())
2664 return false; 2664 return false;
2665 if ( incCounter % modulo == 0 ) 2665 if ( incCounter % modulo == 0 )
2666 syncManager->showProgressBar(incCounter); 2666 syncManager->showProgressBar(incCounter);
2667 uid = el[ incCounter ]; 2667 uid = el[ incCounter ];
2668 bool skipIncidence = false; 2668 bool skipIncidence = false;
2669 if ( uid.left(19) == QString("last-syncAddressee-") ) 2669 if ( uid.left(19) == QString("last-syncAddressee-") )
2670 skipIncidence = true; 2670 skipIncidence = true;
2671 if ( !skipIncidence ) { 2671 if ( !skipIncidence ) {
2672 inL = local->findByUid( uid ); 2672 inL = local->findByUid( uid );
2673 inR = remote->findByUid( uid ); 2673 inR = remote->findByUid( uid );
2674 if ( inR.isEmpty() ) { 2674 if ( inR.isEmpty() ) {
2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2678 local->removeAddressee( inL ); 2678 local->removeAddressee( inL );
2679 ++deletedAddresseeL; 2679 ++deletedAddresseeL;
2680 } else { 2680 } else {
2681 if ( ! syncManager->mWriteBackExistingOnly ) { 2681 if ( ! syncManager->mWriteBackExistingOnly ) {
2682 inL.removeID(mCurrentSyncDevice ); 2682 inL.removeID(mCurrentSyncDevice );
2683 ++addedAddresseeR; 2683 ++addedAddresseeR;
2684 inL.setRevision( modifiedCalendar ); 2684 inL.setRevision( modifiedCalendar );
2685 local->insertAddressee( inL, false ); 2685 local->insertAddressee( inL, false );
2686 inR = inL; 2686 inR = inL;
2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2688 inR.setResource( 0 ); 2688 inR.setResource( 0 );
2689 remote->insertAddressee( inR, false ); 2689 remote->insertAddressee( inR, false );
2690 } 2690 }
2691 } 2691 }
2692 } else { 2692 } else {
2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2695 local->removeAddressee( inL ); 2695 local->removeAddressee( inL );
2696 ++deletedAddresseeL; 2696 ++deletedAddresseeL;
2697 } else { 2697 } else {
2698 if ( ! syncManager->mWriteBackExistingOnly ) { 2698 if ( ! syncManager->mWriteBackExistingOnly ) {
2699 ++addedAddresseeR; 2699 ++addedAddresseeR;
2700 inL.setRevision( modifiedCalendar ); 2700 inL.setRevision( modifiedCalendar );
2701 local->insertAddressee( inL, false ); 2701 local->insertAddressee( inL, false );
2702 inR = inL; 2702 inR = inL;
2703 inR.setResource( 0 ); 2703 inR.setResource( 0 );
2704 remote->insertAddressee( inR, false ); 2704 remote->insertAddressee( inR, false );
2705 } 2705 }
2706 } 2706 }
2707 } 2707 }
2708 } 2708 }
2709 } 2709 }
2710 ++incCounter; 2710 ++incCounter;
2711 } 2711 }
2712 el.clear(); 2712 el.clear();
2713 syncManager->hideProgressBar(); 2713 syncManager->hideProgressBar();
2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2715 // get rid of micro seconds 2715 // get rid of micro seconds
2716 QTime t = mLastAddressbookSync.time(); 2716 QTime t = mLastAddressbookSync.time();
2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2718 addresseeLSync.setRevision( mLastAddressbookSync ); 2718 addresseeLSync.setRevision( mLastAddressbookSync );
2719 addresseeRSync.setRevision( mLastAddressbookSync ); 2719 addresseeRSync.setRevision( mLastAddressbookSync );
2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2726 addresseeRSync.setNote( "" ) ; 2726 addresseeRSync.setNote( "" ) ;
2727 addresseeLSync.setNote( "" ); 2727 addresseeLSync.setNote( "" );
2728 2728
2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2730 remote->insertAddressee( addresseeRSync, false ); 2730 remote->insertAddressee( addresseeRSync, false );
2731 local->insertAddressee( addresseeLSync, false ); 2731 local->insertAddressee( addresseeLSync, false );
2732 QString mes; 2732 QString mes;
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 ); 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 );
2734 if ( syncManager->mShowSyncSummary ) { 2734 if ( syncManager->mShowSyncSummary ) {
2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2736 } 2736 }
2737 qDebug( mes ); 2737 qDebug( mes );
2738 return syncOK; 2738 return syncOK;
2739} 2739}
2740 2740
2741 2741
2742//this is a overwritten callbackmethods from the syncinterface 2742//this is a overwritten callbackmethods from the syncinterface
2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2744{ 2744{
2745 2745
2746 //pending prepare addresseeview for output 2746 //pending prepare addresseeview for output
2747 //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
2748 mGlobalSyncMode = SYNC_MODE_NORMAL; 2748 mGlobalSyncMode = SYNC_MODE_NORMAL;
2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2750 2750
2751 AddressBook abLocal(filename,"syncContact"); 2751 AddressBook abLocal(filename,"syncContact");
2752 bool syncOK = false; 2752 bool syncOK = false;
2753 if ( abLocal.load() ) { 2753 if ( abLocal.load() ) {
2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2755 bool external = false; 2755 bool external = false;
2756 bool isXML = false; 2756 bool isXML = false;
2757 if ( filename.right(4) == ".xml") { 2757 if ( filename.right(4) == ".xml") {
2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2759 isXML = true; 2759 isXML = true;
2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2761 } else { 2761 } else {
2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2763 if ( ! lse.isEmpty() ) { 2763 if ( ! lse.isEmpty() ) {
2764 if ( lse.familyName().left(4) == "!E: " ) 2764 if ( lse.familyName().left(4) == "!E: " )
2765 external = true; 2765 external = true;
2766 } else { 2766 } else {
2767 bool found = false; 2767 bool found = false;
2768 AddressBook::Iterator it; 2768 AddressBook::Iterator it;
2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2770 if ( (*it).revision().date().year() > 2003 ) { 2770 if ( (*it).revision().date().year() > 2003 ) {
2771 found = true; 2771 found = true;
2772 break; 2772 break;
2773 } 2773 }
2774 } 2774 }
2775 external = ! found; 2775 external = ! found;
2776 } 2776 }
2777 2777
2778 if ( external ) { 2778 if ( external ) {
2779 qDebug("Setting vcf mode to external "); 2779 qDebug("Setting vcf mode to external ");
2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2781 AddressBook::Iterator it; 2781 AddressBook::Iterator it;
2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2783 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2783 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2784 (*it).computeCsum( mCurrentSyncDevice ); 2784 (*it).computeCsum( mCurrentSyncDevice );
2785 } 2785 }
2786 } 2786 }
2787 } 2787 }
2788 //AddressBook::Iterator it; 2788 //AddressBook::Iterator it;
2789 //QStringList vcards; 2789 //QStringList vcards;
2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2791 // qDebug("Name %s ", (*it).familyName().latin1()); 2791 // qDebug("Name %s ", (*it).familyName().latin1());
2792 //} 2792 //}
2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2794 if ( syncOK ) { 2794 if ( syncOK ) {
2795 if ( syncManager->mWriteBackFile ) 2795 if ( syncManager->mWriteBackFile )
2796 { 2796 {
2797 if ( external ) 2797 if ( external )
2798 abLocal.removeSyncAddressees( !isXML); 2798 abLocal.removeSyncAddressees( !isXML);
2799 qDebug("Saving remote AB "); 2799 qDebug("Saving remote AB ");
2800 abLocal.saveAB(); 2800 abLocal.saveAB();
2801 if ( isXML ) { 2801 if ( isXML ) {
2802 // afterwrite processing 2802 // afterwrite processing
2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2804 } 2804 }
2805 } 2805 }
2806 } 2806 }
2807 setModified(); 2807 setModified();
2808 2808
2809 } 2809 }
2810 if ( syncOK ) 2810 if ( syncOK )
2811 mViewManager->refreshView(); 2811 mViewManager->refreshView();
2812 return syncOK; 2812 return syncOK;
2813#if 0 2813#if 0
2814 2814
2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2816 getEventViewerDialog()->setSyncMode( true ); 2816 getEventViewerDialog()->setSyncMode( true );
2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2818 getEventViewerDialog()->setSyncMode( false ); 2818 getEventViewerDialog()->setSyncMode( false );
2819 if ( syncOK ) { 2819 if ( syncOK ) {
2820 if ( KOPrefs::instance()->mWriteBackFile ) 2820 if ( KOPrefs::instance()->mWriteBackFile )
2821 { 2821 {
2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2823 storage->save(); 2823 storage->save();
2824 } 2824 }
2825 } 2825 }
2826 setModified(); 2826 setModified();
2827 } 2827 }
2828 2828
2829#endif 2829#endif
2830} 2830}
2831 2831
2832 2832
2833//this is a overwritten callbackmethods from the syncinterface 2833//this is a overwritten callbackmethods from the syncinterface
2834bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2834bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2835{ 2835{
2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2837 2837
2838 AddressBook abLocal( resource,"syncContact"); 2838 AddressBook abLocal( resource,"syncContact");
2839 bool syncOK = false; 2839 bool syncOK = false;
2840 if ( abLocal.load() ) { 2840 if ( abLocal.load() ) {
2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2845 if ( syncOK ) { 2845 if ( syncOK ) {
2846 if ( syncManager->mWriteBackFile ) { 2846 if ( syncManager->mWriteBackFile ) {
2847 abLocal.saveAB(); 2847 abLocal.saveAB();
2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2849 } 2849 }
2850 } 2850 }
2851 setModified(); 2851 setModified();
2852 } 2852 }
2853 if ( syncOK ) 2853 if ( syncOK )
2854 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2855 return syncOK; 2855 return syncOK;
2856 2856
2857} 2857}
2858 2858
2859void KABCore::getFile( bool success ) 2859void KABCore::getFile( bool success )
2860{ 2860{
2861 qDebug("KABCore::getFile ");
2862 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2861 if ( ! success ) { 2863 if ( ! success ) {
2862 setCaption( i18n("Error receiving file. Nothing changed!") ); 2864 setCaption( i18n("Error receiving file. Nothing changed!") );
2863 return; 2865 return;
2864 } 2866 }
2865 mAddressBook->importFromFile( sentSyncFile() ); 2867 mAddressBook->importFromFile( sentSyncFile() );
2866 setCaption( i18n("Pi-Sync successful!") ); 2868 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2867} 2869}
2868void KABCore::syncFileRequest() 2870void KABCore::syncFileRequest()
2869{ 2871{
2870 mAddressBook->export2File( sentSyncFile() ); 2872 mAddressBook->export2File( sentSyncFile() );
2871} 2873}
2872QString KABCore::sentSyncFile() 2874QString KABCore::sentSyncFile()
2873{ 2875{
2874#ifdef _WIN32_ 2876#ifdef _WIN32_
2875 return locateLocal( "tmp", "syncab.ics" ); 2877 return locateLocal( "tmp", "copysyncab.vcf" );
2876#else 2878#else
2877 return QString( "/tmp/kapitempfile.vcf" ); 2879 return QString( "/tmp/copysyncab.vcf" );
2878#endif 2880#endif
2879} 2881}
2880 2882
2883void KABCore::setCaptionBack()
2884{
2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2886}
2881 2887
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 987369d..c628399 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,481 +1,482 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <ksyncmanager.h> 35#include <ksyncmanager.h>
36 36
37namespace KABC { 37namespace KABC {
38class AddressBook; 38class AddressBook;
39} 39}
40 40
41#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
42class KAboutData; 42class KAboutData;
43class KConfig; 43class KConfig;
44 44
45class KAddressBookService; 45class KAddressBookService;
46class LDAPSearchDialog; 46class LDAPSearchDialog;
47#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
48class KAddressBookMain; 48class KAddressBookMain;
49//US class QAction; 49//US class QAction;
50#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
51class KCMultiDialog; 51class KCMultiDialog;
52class KXMLGUIClient; 52class KXMLGUIClient;
53class ExtensionManager; 53class ExtensionManager;
54class XXPortManager; 54class XXPortManager;
55class JumpButtonBar; 55class JumpButtonBar;
56class IncSearchWidget; 56class IncSearchWidget;
57class KDGanttMinimizeSplitter; 57class KDGanttMinimizeSplitter;
58class KAction; 58class KAction;
59class KActionCollection; 59class KActionCollection;
60class KToggleAction; 60class KToggleAction;
61class KSyncProfile; 61class KSyncProfile;
62 62
63class QAction; 63class QAction;
64class QMenuBar; 64class QMenuBar;
65class QSplitter; 65class QSplitter;
66class ViewContainer; 66class ViewContainer;
67class ViewManager; 67class ViewManager;
68class AddresseeEditorDialog; 68class AddresseeEditorDialog;
69class Ir; 69class Ir;
70 70
71class KABCore : public QWidget, public KSyncInterface 71class KABCore : public QWidget, public KSyncInterface
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75 public: 75 public:
76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
77 77
78 78
79 ~KABCore(); 79 ~KABCore();
80 80
81 81
82#ifdef KAB_EMBEDDED 82#ifdef KAB_EMBEDDED
83 //US added functionality 83 //US added functionality
84 QPopupMenu* getViewMenu() {return viewMenu;} 84 QPopupMenu* getViewMenu() {return viewMenu;}
85 QPopupMenu* getFilterMenu() {return filterMenu;} 85 QPopupMenu* getFilterMenu() {return filterMenu;}
86 QPopupMenu* getSettingsMenu() {return settingsMenu;} 86 QPopupMenu* getSettingsMenu() {return settingsMenu;}
87 void addActionsManually(); 87 void addActionsManually();
88#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
89 /** 89 /**
90 Restores the global settings. 90 Restores the global settings.
91 */ 91 */
92 void restoreSettings(); 92 void restoreSettings();
93 93
94 /** 94 /**
95 Saves the global settings. 95 Saves the global settings.
96 */ 96 */
97 void saveSettings(); 97 void saveSettings();
98 98
99 /** 99 /**
100 Returns a pointer to the StdAddressBook of the application. 100 Returns a pointer to the StdAddressBook of the application.
101 */ 101 */
102 KABC::AddressBook *addressBook() const; 102 KABC::AddressBook *addressBook() const;
103 103
104 /** 104 /**
105 Returns a pointer to the KConfig object of the application. 105 Returns a pointer to the KConfig object of the application.
106 */ 106 */
107 static KConfig *config(); 107 static KConfig *config();
108 108
109 /** 109 /**
110 Returns a pointer to the global KActionCollection object. So 110 Returns a pointer to the global KActionCollection object. So
111 other classes can register their actions easily. 111 other classes can register their actions easily.
112 */ 112 */
113 KActionCollection *actionCollection() const; 113 KActionCollection *actionCollection() const;
114 114
115 /** 115 /**
116 Returns the current search field of the Incremental Search Widget. 116 Returns the current search field of the Incremental Search Widget.
117 */ 117 */
118 KABC::Field *currentSearchField() const; 118 KABC::Field *currentSearchField() const;
119 119
120 /** 120 /**
121 Returns the uid list of the currently selected contacts. 121 Returns the uid list of the currently selected contacts.
122 */ 122 */
123 QStringList selectedUIDs() const; 123 QStringList selectedUIDs() const;
124 124
125 /** 125 /**
126 Displays the ResourceSelectDialog and returns the selected 126 Displays the ResourceSelectDialog and returns the selected
127 resource or a null pointer if no resource was selected by 127 resource or a null pointer if no resource was selected by
128 the user. 128 the user.
129 */ 129 */
130 KABC::Resource *requestResource( QWidget *parent ); 130 KABC::Resource *requestResource( QWidget *parent );
131 131
132#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
133 static KAboutData *createAboutData(); 133 static KAboutData *createAboutData();
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 135
136#ifdef KAB_EMBEDDED 136#ifdef KAB_EMBEDDED
137 inline QPopupMenu* getImportMenu() { return ImportMenu;} 137 inline QPopupMenu* getImportMenu() { return ImportMenu;}
138 inline QPopupMenu* getExportMenu() { return ExportMenu;} 138 inline QPopupMenu* getExportMenu() { return ExportMenu;}
139#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
140 140
141 public slots: 141 public slots:
142#ifdef KAB_EMBEDDED 142#ifdef KAB_EMBEDDED
143 void createAboutData(); 143 void createAboutData();
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 void statusMessage(QString, int time = 0 ); 146 void statusMessage(QString, int time = 0 );
147 void showLicence(); 147 void showLicence();
148 void faq(); 148 void faq();
149 149
150 /** 150 /**
151 Is called whenever a contact is selected in the view. 151 Is called whenever a contact is selected in the view.
152 */ 152 */
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 getFile( bool success );
346 void syncFileRequest(); 346 void syncFileRequest();
347 void setDetailsVisible( bool visible ); 347 void setDetailsVisible( bool visible );
348 void setDetailsToState(); 348 void setDetailsToState();
349 // void slotSyncMenu( int ); 349 // void slotSyncMenu( int );
350 private slots: 350 private slots:
351 void setJumpButtonBarVisible( bool visible ); 351 void setJumpButtonBarVisible( bool visible );
352 void setCaptionBack();
352 void importFromOL(); 353 void importFromOL();
353 void extensionModified( const KABC::Addressee::List &list ); 354 void extensionModified( const KABC::Addressee::List &list );
354 void extensionChanged( int id ); 355 void extensionChanged( int id );
355 void clipboardDataChanged(); 356 void clipboardDataChanged();
356 void updateActionMenu(); 357 void updateActionMenu();
357 void configureKeyBindings(); 358 void configureKeyBindings();
358 void removeVoice(); 359 void removeVoice();
359#ifdef KAB_EMBEDDED 360#ifdef KAB_EMBEDDED
360 void configureResources(); 361 void configureResources();
361#endif //KAB_EMBEDDED 362#endif //KAB_EMBEDDED
362 363
363 void slotEditorDestroyed( const QString &uid ); 364 void slotEditorDestroyed( const QString &uid );
364 void configurationChanged(); 365 void configurationChanged();
365 void addressBookChanged(); 366 void addressBookChanged();
366 367
367 private: 368 private:
368 void initGUI(); 369 void initGUI();
369 void initActions(); 370 void initActions();
370 371
371 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 372 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
372 const char *name = 0 ); 373 const char *name = 0 );
373 374
374 KXMLGUIClient *mGUIClient; 375 KXMLGUIClient *mGUIClient;
375 376
376 KABC::AddressBook *mAddressBook; 377 KABC::AddressBook *mAddressBook;
377 378
378 ViewManager *mViewManager; 379 ViewManager *mViewManager;
379 // QSplitter *mDetailsSplitter; 380 // QSplitter *mDetailsSplitter;
380 KDGanttMinimizeSplitter *mExtensionBarSplitter; 381 KDGanttMinimizeSplitter *mExtensionBarSplitter;
381 ViewContainer *mDetails; 382 ViewContainer *mDetails;
382 KDGanttMinimizeSplitter* mMiniSplitter; 383 KDGanttMinimizeSplitter* mMiniSplitter;
383 XXPortManager *mXXPortManager; 384 XXPortManager *mXXPortManager;
384 JumpButtonBar *mJumpButtonBar; 385 JumpButtonBar *mJumpButtonBar;
385 IncSearchWidget *mIncSearchWidget; 386 IncSearchWidget *mIncSearchWidget;
386 ExtensionManager *mExtensionManager; 387 ExtensionManager *mExtensionManager;
387 388
388 KCMultiDialog *mConfigureDialog; 389 KCMultiDialog *mConfigureDialog;
389 390
390#ifndef KAB_EMBEDDED 391#ifndef KAB_EMBEDDED
391 LDAPSearchDialog *mLdapSearchDialog; 392 LDAPSearchDialog *mLdapSearchDialog;
392#endif //KAB_EMBEDDED 393#endif //KAB_EMBEDDED
393 // QDict<AddresseeEditorDialog> mEditorDict; 394 // QDict<AddresseeEditorDialog> mEditorDict;
394 AddresseeEditorDialog *mEditorDialog; 395 AddresseeEditorDialog *mEditorDialog;
395 bool mReadWrite; 396 bool mReadWrite;
396 bool mModified; 397 bool mModified;
397 bool mIsPart; 398 bool mIsPart;
398 bool mMultipleViewsAtOnce; 399 bool mMultipleViewsAtOnce;
399 400
400 401
401 //US file menu 402 //US file menu
402 KAction *mActionMail; 403 KAction *mActionMail;
403 KAction *mActionBeam; 404 KAction *mActionBeam;
404 KAction *mActionExport2phone; 405 KAction *mActionExport2phone;
405 KAction* mActionPrint; 406 KAction* mActionPrint;
406 KAction* mActionNewContact; 407 KAction* mActionNewContact;
407 KAction *mActionSave; 408 KAction *mActionSave;
408 KAction *mActionEditAddressee; 409 KAction *mActionEditAddressee;
409 KAction *mActionMailVCard; 410 KAction *mActionMailVCard;
410 KAction *mActionBeamVCard; 411 KAction *mActionBeamVCard;
411 412
412 KAction *mActionQuit; 413 KAction *mActionQuit;
413 414
414 //US edit menu 415 //US edit menu
415 KAction *mActionCopy; 416 KAction *mActionCopy;
416 KAction *mActionCut; 417 KAction *mActionCut;
417 KAction *mActionPaste; 418 KAction *mActionPaste;
418 KAction *mActionSelectAll; 419 KAction *mActionSelectAll;
419 KAction *mActionUndo; 420 KAction *mActionUndo;
420 KAction *mActionRedo; 421 KAction *mActionRedo;
421 KAction *mActionDelete; 422 KAction *mActionDelete;
422 423
423 //US settings menu 424 //US settings menu
424 KAction *mActionConfigResources; 425 KAction *mActionConfigResources;
425 KAction *mActionConfigKAddressbook; 426 KAction *mActionConfigKAddressbook;
426 KAction *mActionConfigShortcuts; 427 KAction *mActionConfigShortcuts;
427 KAction *mActionConfigureToolbars; 428 KAction *mActionConfigureToolbars;
428 KAction *mActionKeyBindings; 429 KAction *mActionKeyBindings;
429 KToggleAction *mActionJumpBar; 430 KToggleAction *mActionJumpBar;
430 KToggleAction *mActionDetails; 431 KToggleAction *mActionDetails;
431 KAction *mActionWhoAmI; 432 KAction *mActionWhoAmI;
432 KAction *mActionCategories; 433 KAction *mActionCategories;
433 KAction *mActionAboutKAddressbook; 434 KAction *mActionAboutKAddressbook;
434 KAction *mActionLicence; 435 KAction *mActionLicence;
435 KAction *mActionFaq; 436 KAction *mActionFaq;
436 437
437 KAction *mActionDeleteView; 438 KAction *mActionDeleteView;
438 439
439 QPopupMenu *viewMenu; 440 QPopupMenu *viewMenu;
440 QPopupMenu *filterMenu; 441 QPopupMenu *filterMenu;
441 QPopupMenu *settingsMenu; 442 QPopupMenu *settingsMenu;
442 QPopupMenu *changeMenu; 443 QPopupMenu *changeMenu;
443//US QAction *mActionSave; 444//US QAction *mActionSave;
444 QPopupMenu *ImportMenu; 445 QPopupMenu *ImportMenu;
445 QPopupMenu *ExportMenu; 446 QPopupMenu *ExportMenu;
446 //LR additional methods 447 //LR additional methods
447 KAction *mActionRemoveVoice; 448 KAction *mActionRemoveVoice;
448 KAction * mActionImportOL; 449 KAction * mActionImportOL;
449 450
450#ifndef KAB_EMBEDDED 451#ifndef KAB_EMBEDDED
451 KAddressBookService *mAddressBookService; 452 KAddressBookService *mAddressBookService;
452#endif //KAB_EMBEDDED 453#endif //KAB_EMBEDDED
453 454
454 class KABCorePrivate; 455 class KABCorePrivate;
455 KABCorePrivate *d; 456 KABCorePrivate *d;
456 //US bool mBlockSaveFlag; 457 //US bool mBlockSaveFlag;
457 458
458#ifdef KAB_EMBEDDED 459#ifdef KAB_EMBEDDED
459 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 460 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
460#endif //KAB_EMBEDDED 461#endif //KAB_EMBEDDED
461 462
462 //this are the overwritten callbackmethods from the syncinterface 463 //this are the overwritten callbackmethods from the syncinterface
463 virtual bool sync(KSyncManager* manager, QString filename, int mode); 464 virtual bool sync(KSyncManager* manager, QString filename, int mode);
464 virtual bool syncExternal(KSyncManager* manager, QString resource); 465 virtual bool syncExternal(KSyncManager* manager, QString resource);
465 466
466 467
467 // LR ******************************* 468 // LR *******************************
468 // sync stuff! 469 // sync stuff!
469 QString sentSyncFile(); 470 QString sentSyncFile();
470 QPopupMenu *syncMenu; 471 QPopupMenu *syncMenu;
471 KSyncManager* syncManager; 472 KSyncManager* syncManager;
472 int mGlobalSyncMode; 473 int mGlobalSyncMode;
473 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
474 KABC::Addressee getLastSyncAddressee(); 475 KABC::Addressee getLastSyncAddressee();
475 QDateTime mLastAddressbookSync; 476 QDateTime mLastAddressbookSync;
476 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 477 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
477 // ********************* 478 // *********************
478 479
479}; 480};
480 481
481#endif 482#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index b360644..a663427 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1169 +1,1148 @@
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#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51 51
52#include <klocale.h> 52#include <klocale.h>
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kconfig.h> 54#include <kconfig.h>
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79//LR ok 79//LR ok
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 KSyncProfile* temp = new KSyncProfile (); 104 KSyncProfile* temp = new KSyncProfile ();
105 temp->setName( prof[0] ); 105 temp->setName( prof[0] );
106 temp->writeConfig(&config); 106 temp->writeConfig(&config);
107 temp->setName( prof[1] ); 107 temp->setName( prof[1] );
108 temp->writeConfig(&config); 108 temp->writeConfig(&config);
109 config.setGroup("General"); 109 config.setGroup("General");
110 config.writeEntry("SyncProfileNames",prof); 110 config.writeEntry("SyncProfileNames",prof);
111 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 111 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
112 config.sync(); 112 config.sync();
113 delete temp; 113 delete temp;
114 } 114 }
115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
116 mSyncProfileNames = prof; 116 mSyncProfileNames = prof;
117 unsigned int i; 117 unsigned int i;
118 for ( i = 0; i < prof.count(); ++i ) { 118 for ( i = 0; i < prof.count(); ++i ) {
119 mSyncMenu->insertItem( prof[i], 1000+i ); 119 mSyncMenu->insertItem( prof[i], 1000+i );
120 if ( i == 2 ) 120 if ( i == 2 )
121 mSyncMenu->insertSeparator(); 121 mSyncMenu->insertSeparator();
122 } 122 }
123 QDir app_dir; 123 QDir app_dir;
124 //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
125 if ( mTargetApp == PWMPI) { 125 if ( mTargetApp == PWMPI) {
126 mSyncMenu->removeItem( 1000 ); 126 mSyncMenu->removeItem( 1000 );
127 } 127 }
128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
129 mSyncMenu->setItemEnabled( 1000, false ); 129 mSyncMenu->setItemEnabled( 1000, false );
130 } 130 }
131} 131}
132 132
133void KSyncManager::slotSyncMenu( int action ) 133void KSyncManager::slotSyncMenu( int action )
134{ 134{
135 //qDebug("syncaction %d ", action); 135 //qDebug("syncaction %d ", action);
136 if ( action == 0 ) { 136 if ( action == 0 ) {
137 137
138 // seems to be a Qt2 event handling bug 138 // seems to be a Qt2 event handling bug
139 // syncmenu.clear causes a segfault at first time 139 // syncmenu.clear causes a segfault at first time
140 // 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
141 // 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
142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
143 //confSync(); 143 //confSync();
144 144
145 return; 145 return;
146 } 146 }
147 if ( action == 1 ) { 147 if ( action == 1 ) {
148 multiSync( true ); 148 multiSync( true );
149 return; 149 return;
150 } 150 }
151 if ( action == 2 ) { 151 if ( action == 2 ) {
152 enableQuick(); 152 enableQuick();
153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
154 return; 154 return;
155 } 155 }
156 if ( action == 3 ) { 156 if ( action == 3 ) {
157 delete mServerSocket; 157 delete mServerSocket;
158 mServerSocket = 0; 158 mServerSocket = 0;
159 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 159 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
160 return; 160 return;
161 } 161 }
162 162
163 if (blockSave()) 163 if (blockSave())
164 return; 164 return;
165 165
166 setBlockSave(true); 166 setBlockSave(true);
167 167
168 mCurrentSyncProfile = action - 1000 ; 168 mCurrentSyncProfile = action - 1000 ;
169 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 169 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
170 mCurrentSyncName = mLocalMachineName ; 170 mCurrentSyncName = mLocalMachineName ;
171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
172 KSyncProfile* temp = new KSyncProfile (); 172 KSyncProfile* temp = new KSyncProfile ();
173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
174 temp->readConfig(&config); 174 temp->readConfig(&config);
175 mAskForPreferences = temp->getAskForPreferences(); 175 mAskForPreferences = temp->getAskForPreferences();
176 mSyncAlgoPrefs = temp->getSyncPrefs(); 176 mSyncAlgoPrefs = temp->getSyncPrefs();
177 mWriteBackFile = temp->getWriteBackFile(); 177 mWriteBackFile = temp->getWriteBackFile();
178 mWriteBackExistingOnly = temp->getWriteBackExisting(); 178 mWriteBackExistingOnly = temp->getWriteBackExisting();
179 mWriteBackInFuture = 0; 179 mWriteBackInFuture = 0;
180 if ( temp->getWriteBackFuture() ) 180 if ( temp->getWriteBackFuture() )
181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
182 mShowSyncSummary = temp->getShowSummaryAfterSync(); 182 mShowSyncSummary = temp->getShowSummaryAfterSync();
183 if ( action == 1000 ) { 183 if ( action == 1000 ) {
184 syncSharp(); 184 syncSharp();
185 185
186 } else if ( action == 1001 ) { 186 } else if ( action == 1001 ) {
187 syncLocalFile(); 187 syncLocalFile();
188 188
189 } else if ( action == 1002 ) { 189 } else if ( action == 1002 ) {
190 quickSyncLocalFile(); 190 quickSyncLocalFile();
191 191
192 } else if ( action >= 1003 ) { 192 } else if ( action >= 1003 ) {
193 if ( temp->getIsLocalFileSync() ) { 193 if ( temp->getIsLocalFileSync() ) {
194 switch(mTargetApp) 194 switch(mTargetApp)
195 { 195 {
196 case (KAPI): 196 case (KAPI):
197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
198 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 198 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
199 break; 199 break;
200 case (KOPI): 200 case (KOPI):
201 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 201 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
202 mLastSyncedLocalFile = temp->getRemoteFileName(); 202 mLastSyncedLocalFile = temp->getRemoteFileName();
203 break; 203 break;
204 case (PWMPI): 204 case (PWMPI):
205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
207 break; 207 break;
208 default: 208 default:
209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
210 break; 210 break;
211 211
212 } 212 }
213 } else { 213 } else {
214 if ( temp->getIsPhoneSync() ) { 214 if ( temp->getIsPhoneSync() ) {
215 mPhoneDevice = temp->getPhoneDevice( ) ; 215 mPhoneDevice = temp->getPhoneDevice( ) ;
216 mPhoneConnection = temp->getPhoneConnection( ); 216 mPhoneConnection = temp->getPhoneConnection( );
217 mPhoneModel = temp->getPhoneModel( ); 217 mPhoneModel = temp->getPhoneModel( );
218 syncPhone(); 218 syncPhone();
219 } else if ( temp->getIsPiSync() ) { 219 } else if ( temp->getIsPiSync() ) {
220 if ( mTargetApp == KAPI ) { 220 if ( mTargetApp == KAPI ) {
221 mPassWordPiSync = temp->getRemotePwAB(); 221 mPassWordPiSync = temp->getRemotePwAB();
222 mActiveSyncPort = temp->getRemotePortAB(); 222 mActiveSyncPort = temp->getRemotePortAB();
223 mActiveSyncIP = temp->getRemoteIPAB(); 223 mActiveSyncIP = temp->getRemoteIPAB();
224 } else if ( mTargetApp == KOPI ) { 224 } else if ( mTargetApp == KOPI ) {
225 mPassWordPiSync = temp->getRemotePw(); 225 mPassWordPiSync = temp->getRemotePw();
226 mActiveSyncPort = temp->getRemotePort(); 226 mActiveSyncPort = temp->getRemotePort();
227 mActiveSyncIP = temp->getRemoteIP(); 227 mActiveSyncIP = temp->getRemoteIP();
228 } else { 228 } else {
229 mPassWordPiSync = temp->getRemotePwPWM(); 229 mPassWordPiSync = temp->getRemotePwPWM();
230 mActiveSyncPort = temp->getRemotePortPWM(); 230 mActiveSyncPort = temp->getRemotePortPWM();
231 mActiveSyncIP = temp->getRemoteIPPWM(); 231 mActiveSyncIP = temp->getRemoteIPPWM();
232 } 232 }
233 syncPi(); 233 syncPi();
234 } 234 } else
235 syncRemote( temp ); 235 syncRemote( temp );
236 236
237 } 237 }
238 } 238 }
239 delete temp; 239 delete temp;
240 setBlockSave(false); 240 setBlockSave(false);
241} 241}
242void KSyncManager::enableQuick() 242void KSyncManager::enableQuick()
243{ 243{
244 QDialog dia ( 0, "input-dialog", true ); 244 QDialog dia ( 0, "input-dialog", true );
245 QLineEdit lab ( &dia ); 245 QLineEdit lab ( &dia );
246 QVBoxLayout lay( &dia ); 246 QVBoxLayout lay( &dia );
247 lab.setText( mPrefs->mPassiveSyncPort ); 247 lab.setText( mPrefs->mPassiveSyncPort );
248 lay.setMargin(7); 248 lay.setMargin(7);
249 lay.setSpacing(7); 249 lay.setSpacing(7);
250 int po = 9197+mTargetApp; 250 int po = 9197+mTargetApp;
251 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 251 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
252 lay.addWidget( &label); 252 lay.addWidget( &label);
253 lay.addWidget( &lab); 253 lay.addWidget( &lab);
254 254
255 QLineEdit lepw ( &dia ); 255 QLineEdit lepw ( &dia );
256 lepw.setText( mPrefs->mPassiveSyncPw ); 256 lepw.setText( mPrefs->mPassiveSyncPw );
257 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 257 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
258 lay.addWidget( &label2); 258 lay.addWidget( &label2);
259 lay.addWidget( &lepw); 259 lay.addWidget( &lepw);
260 dia.setFixedSize( 230,80 ); 260 dia.setFixedSize( 230,80 );
261 dia.setCaption( i18n("Enter port for Pi-Sync") ); 261 dia.setCaption( i18n("Enter port for Pi-Sync") );
262 QPushButton pb ( "OK", &dia); 262 QPushButton pb ( "OK", &dia);
263 lay.addWidget( &pb ); 263 lay.addWidget( &pb );
264 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 264 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
265 dia.show(); 265 dia.show();
266 if ( ! dia.exec() ) 266 if ( ! dia.exec() )
267 return; 267 return;
268 dia.hide(); 268 dia.hide();
269 qApp->processEvents(); 269 qApp->processEvents();
270 mPrefs->mPassiveSyncPw = lepw.text(); 270 mPrefs->mPassiveSyncPw = lepw.text();
271 mPrefs->mPassiveSyncPort = lab.text(); 271 mPrefs->mPassiveSyncPort = lab.text();
272 bool ok; 272 bool ok;
273 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 273 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
274 if ( ! ok ) { 274 if ( ! ok ) {
275 KMessageBox::information( 0, i18n("No valid port")); 275 KMessageBox::information( 0, i18n("No valid port"));
276 return; 276 return;
277 } 277 }
278 //qDebug("port %d ", port); 278 //qDebug("port %d ", port);
279 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 279 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
280 mServerSocket->setFileName( defaultFileName() ); 280 mServerSocket->setFileName( defaultFileName() );
281 //qDebug("connected "); 281 //qDebug("connected ");
282 if ( !mServerSocket->ok() ) { 282 if ( !mServerSocket->ok() ) {
283 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 283 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
284 delete mServerSocket; 284 delete mServerSocket;
285 mServerSocket = 0; 285 mServerSocket = 0;
286 return; 286 return;
287 } 287 }
288 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); 288 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
289 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 289 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
290 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 290 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
291} 291}
292 292
293void KSyncManager::syncLocalFile() 293void KSyncManager::syncLocalFile()
294{ 294{
295 295
296 QString fn =mLastSyncedLocalFile; 296 QString fn =mLastSyncedLocalFile;
297 QString ext; 297 QString ext;
298 298
299 switch(mTargetApp) 299 switch(mTargetApp)
300 { 300 {
301 case (KAPI): 301 case (KAPI):
302 ext = "(*.vcf)"; 302 ext = "(*.vcf)";
303 break; 303 break;
304 case (KOPI): 304 case (KOPI):
305 ext = "(*.ics/*.vcs)"; 305 ext = "(*.ics/*.vcs)";
306 break; 306 break;
307 case (PWMPI): 307 case (PWMPI):
308 ext = "(*.pwm)"; 308 ext = "(*.pwm)";
309 break; 309 break;
310 default: 310 default:
311 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 311 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
312 break; 312 break;
313 313
314 } 314 }
315 315
316 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 316 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
317 if ( fn == "" ) 317 if ( fn == "" )
318 return; 318 return;
319 if ( syncWithFile( fn, false ) ) { 319 if ( syncWithFile( fn, false ) ) {
320 qDebug("syncLocalFile() successful "); 320 qDebug("syncLocalFile() successful ");
321 } 321 }
322 322
323} 323}
324bool KSyncManager::syncWithFile( QString fn , bool quick ) 324bool KSyncManager::syncWithFile( QString fn , bool quick )
325{ 325{
326 bool ret = false; 326 bool ret = false;
327 QFileInfo info; 327 QFileInfo info;
328 info.setFile( fn ); 328 info.setFile( fn );
329 QString mess; 329 QString mess;
330 bool loadbup = true; 330 bool loadbup = true;
331 if ( !info. exists() ) { 331 if ( !info. exists() ) {
332 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 332 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
333 int result = QMessageBox::warning( mParent, i18n("Warning!"), 333 int result = QMessageBox::warning( mParent, i18n("Warning!"),
334 mess ); 334 mess );
335 return ret; 335 return ret;
336 } 336 }
337 int result = 0; 337 int result = 0;
338 if ( !quick ) { 338 if ( !quick ) {
339 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 339 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
340 result = QMessageBox::warning( mParent, i18n("Warning!"), 340 result = QMessageBox::warning( mParent, i18n("Warning!"),
341 mess, 341 mess,
342 i18n("Sync"), i18n("Cancel"), 0, 342 i18n("Sync"), i18n("Cancel"), 0,
343 0, 1 ); 343 0, 1 );
344 if ( result ) 344 if ( result )
345 return false; 345 return false;
346 } 346 }
347 if ( mAskForPreferences ) 347 if ( mAskForPreferences )
348 edit_sync_options(); 348 edit_sync_options();
349 if ( result == 0 ) { 349 if ( result == 0 ) {
350 //qDebug("Now sycing ... "); 350 //qDebug("Now sycing ... ");
351 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 351 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
352 mParent->setCaption( i18n("Synchronization successful") ); 352 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
353 else 353 else
354 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 354 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
355 if ( ! quick ) 355 if ( ! quick )
356 mLastSyncedLocalFile = fn; 356 mLastSyncedLocalFile = fn;
357 } 357 }
358 return ret; 358 return ret;
359} 359}
360void KSyncManager::quickSyncLocalFile() 360void KSyncManager::quickSyncLocalFile()
361{ 361{
362 362
363 if ( syncWithFile( mLastSyncedLocalFile, false ) ) { 363 if ( syncWithFile( mLastSyncedLocalFile, false ) ) {
364 qDebug("quick syncLocalFile() successful "); 364 qDebug("quick syncLocalFile() successful ");
365 365
366 } 366 }
367} 367}
368void KSyncManager::multiSync( bool askforPrefs ) 368void KSyncManager::multiSync( bool askforPrefs )
369{ 369{
370 if (blockSave()) 370 if (blockSave())
371 return; 371 return;
372 setBlockSave(true); 372 setBlockSave(true);
373 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 373 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
374 if ( QMessageBox::information( mParent, i18n("Sync"), 374 if ( QMessageBox::information( mParent, i18n("Sync"),
375 question, 375 question,
376 i18n("Yes"), i18n("No"), 376 i18n("Yes"), i18n("No"),
377 0, 0 ) != 0 ) { 377 0, 0 ) != 0 ) {
378 setBlockSave(false); 378 setBlockSave(false);
379 mParent->setCaption(i18n("Aborted! Nothing synced!")); 379 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
380 return; 380 return;
381 } 381 }
382 mCurrentSyncDevice = i18n("Multiple profiles") ; 382 mCurrentSyncDevice = i18n("Multiple profiles") ;
383 mSyncAlgoPrefs = mRingSyncAlgoPrefs; 383 mSyncAlgoPrefs = mRingSyncAlgoPrefs;
384 if ( askforPrefs ) { 384 if ( askforPrefs ) {
385 edit_sync_options(); 385 edit_sync_options();
386 mRingSyncAlgoPrefs = mSyncAlgoPrefs; 386 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
387 } 387 }
388 mParent->setCaption(i18n("Multiple sync started.") ); 388 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
389 qApp->processEvents(); 389 qApp->processEvents();
390 int num = ringSync() ; 390 int num = ringSync() ;
391 if ( num > 1 ) 391 if ( num > 1 )
392 ringSync(); 392 ringSync();
393 setBlockSave(false); 393 setBlockSave(false);
394 if ( num ) 394 if ( num )
395 emit save(); 395 emit save();
396 if ( num ) 396 if ( num )
397 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 397 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
398 else 398 else
399 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 399 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
400 return; 400 return;
401} 401}
402int KSyncManager::ringSync() 402int KSyncManager::ringSync()
403{ 403{
404 int syncedProfiles = 0; 404 int syncedProfiles = 0;
405 unsigned int i; 405 unsigned int i;
406 QTime timer; 406 QTime timer;
407 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 407 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
408 QStringList syncProfileNames = mSyncProfileNames; 408 QStringList syncProfileNames = mSyncProfileNames;
409 KSyncProfile* temp = new KSyncProfile (); 409 KSyncProfile* temp = new KSyncProfile ();
410 mAskForPreferences = false; 410 mAskForPreferences = false;
411 for ( i = 0; i < syncProfileNames.count(); ++i ) { 411 for ( i = 0; i < syncProfileNames.count(); ++i ) {
412 mCurrentSyncProfile = i; 412 mCurrentSyncProfile = i;
413 temp->setName(syncProfileNames[mCurrentSyncProfile]); 413 temp->setName(syncProfileNames[mCurrentSyncProfile]);
414 temp->readConfig(&config); 414 temp->readConfig(&config);
415 415
416 QString includeInRingSync; 416 QString includeInRingSync;
417 switch(mTargetApp) 417 switch(mTargetApp)
418 { 418 {
419 case (KAPI): 419 case (KAPI):
420 includeInRingSync = temp->getIncludeInRingSyncAB(); 420 includeInRingSync = temp->getIncludeInRingSyncAB();
421 break; 421 break;
422 case (KOPI): 422 case (KOPI):
423 includeInRingSync = temp->getIncludeInRingSync(); 423 includeInRingSync = temp->getIncludeInRingSync();
424 break; 424 break;
425 case (PWMPI): 425 case (PWMPI):
426 includeInRingSync = temp->getIncludeInRingSyncPWM(); 426 includeInRingSync = temp->getIncludeInRingSyncPWM();
427 break; 427 break;
428 default: 428 default:
429 qDebug("KSyncManager::ringSync: invalid apptype selected"); 429 qDebug("KSyncManager::ringSync: invalid apptype selected");
430 break; 430 break;
431 431
432 } 432 }
433 433
434 434
435 if ( includeInRingSync && ( i < 1 || i > 2 )) { 435 if ( includeInRingSync && ( i < 1 || i > 2 )) {
436 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 436 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
437 ++syncedProfiles; 437 ++syncedProfiles;
438 // mAskForPreferences = temp->getAskForPreferences(); 438 // mAskForPreferences = temp->getAskForPreferences();
439 mWriteBackFile = temp->getWriteBackFile(); 439 mWriteBackFile = temp->getWriteBackFile();
440 mWriteBackExistingOnly = temp->getWriteBackExisting(); 440 mWriteBackExistingOnly = temp->getWriteBackExisting();
441 mWriteBackInFuture = 0; 441 mWriteBackInFuture = 0;
442 if ( temp->getWriteBackFuture() ) 442 if ( temp->getWriteBackFuture() )
443 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 443 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
444 mShowSyncSummary = false; 444 mShowSyncSummary = false;
445 mCurrentSyncDevice = syncProfileNames[i] ; 445 mCurrentSyncDevice = syncProfileNames[i] ;
446 mCurrentSyncName = mLocalMachineName; 446 mCurrentSyncName = mLocalMachineName;
447 if ( i == 0 ) { 447 if ( i == 0 ) {
448 syncSharp(); 448 syncSharp();
449 } else { 449 } else {
450 if ( temp->getIsLocalFileSync() ) { 450 if ( temp->getIsLocalFileSync() ) {
451 switch(mTargetApp) 451 switch(mTargetApp)
452 { 452 {
453 case (KAPI): 453 case (KAPI):
454 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 454 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
455 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 455 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
456 break; 456 break;
457 case (KOPI): 457 case (KOPI):
458 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 458 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
459 mLastSyncedLocalFile = temp->getRemoteFileName(); 459 mLastSyncedLocalFile = temp->getRemoteFileName();
460 break; 460 break;
461 case (PWMPI): 461 case (PWMPI):
462 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 462 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
463 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 463 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
464 break; 464 break;
465 default: 465 default:
466 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 466 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
467 break; 467 break;
468 } 468 }
469 } else { 469 } else {
470 if ( temp->getIsPhoneSync() ) { 470 if ( temp->getIsPhoneSync() ) {
471 mPhoneDevice = temp->getPhoneDevice( ) ; 471 mPhoneDevice = temp->getPhoneDevice( ) ;
472 mPhoneConnection = temp->getPhoneConnection( ); 472 mPhoneConnection = temp->getPhoneConnection( );
473 mPhoneModel = temp->getPhoneModel( ); 473 mPhoneModel = temp->getPhoneModel( );
474 syncPhone(); 474 syncPhone();
475 } else 475 } else
476 syncRemote( temp, false ); 476 syncRemote( temp, false );
477 477
478 } 478 }
479 } 479 }
480 timer.start(); 480 timer.start();
481 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); 481 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
482 while ( timer.elapsed () < 2000 ) { 482 while ( timer.elapsed () < 2000 ) {
483 qApp->processEvents(); 483 qApp->processEvents();
484#ifndef _WIN32_ 484#ifndef _WIN32_
485 sleep (1); 485 sleep (1);
486#endif 486#endif
487 } 487 }
488 488
489 } 489 }
490 490
491 } 491 }
492 delete temp; 492 delete temp;
493 return syncedProfiles; 493 return syncedProfiles;
494} 494}
495 495
496void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 496void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
497{ 497{
498 QString question; 498 QString question;
499 if ( ask ) { 499 if ( ask ) {
500 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 500 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
501 if ( QMessageBox::information( mParent, i18n("Sync"), 501 if ( QMessageBox::information( mParent, i18n("Sync"),
502 question, 502 question,
503 i18n("Yes"), i18n("No"), 503 i18n("Yes"), i18n("No"),
504 0, 0 ) != 0 ) 504 0, 0 ) != 0 )
505 return; 505 return;
506 } 506 }
507 507
508 QString preCommand; 508 QString preCommand;
509 QString localTempFile; 509 QString localTempFile;
510 QString postCommand; 510 QString postCommand;
511 511
512 switch(mTargetApp) 512 switch(mTargetApp)
513 { 513 {
514 case (KAPI): 514 case (KAPI):
515 preCommand = prof->getPreSyncCommandAB(); 515 preCommand = prof->getPreSyncCommandAB();
516 postCommand = prof->getPostSyncCommandAB(); 516 postCommand = prof->getPostSyncCommandAB();
517 localTempFile = prof->getLocalTempFileAB(); 517 localTempFile = prof->getLocalTempFileAB();
518 break; 518 break;
519 case (KOPI): 519 case (KOPI):
520 preCommand = prof->getPreSyncCommand(); 520 preCommand = prof->getPreSyncCommand();
521 postCommand = prof->getPostSyncCommand(); 521 postCommand = prof->getPostSyncCommand();
522 localTempFile = prof->getLocalTempFile(); 522 localTempFile = prof->getLocalTempFile();
523 break; 523 break;
524 case (PWMPI): 524 case (PWMPI):
525 preCommand = prof->getPreSyncCommandPWM(); 525 preCommand = prof->getPreSyncCommandPWM();
526 postCommand = prof->getPostSyncCommandPWM(); 526 postCommand = prof->getPostSyncCommandPWM();
527 localTempFile = prof->getLocalTempFilePWM(); 527 localTempFile = prof->getLocalTempFilePWM();
528 break; 528 break;
529 default: 529 default:
530 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 530 qDebug("KSyncManager::syncRemote: invalid apptype selected");
531 break; 531 break;
532 } 532 }
533 533
534 534
535 int fi; 535 int fi;
536 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 536 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
537 QString pwd = getPassword(); 537 QString pwd = getPassword();
538 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 538 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
539 539
540 } 540 }
541 int maxlen = 30; 541 int maxlen = 30;
542 if ( QApplication::desktop()->width() > 320 ) 542 if ( QApplication::desktop()->width() > 320 )
543 maxlen += 25; 543 maxlen += 25;
544 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); 544 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
545 int fileSize = 0; 545 int fileSize = 0;
546 int result = system ( preCommand ); 546 int result = system ( preCommand );
547 // 0 : okay 547 // 0 : okay
548 // 256: no such file or dir 548 // 256: no such file or dir
549 // 549 //
550 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 550 qDebug("KO: Remote copy result(0 = okay): %d ",result );
551 if ( result != 0 ) { 551 if ( result != 0 ) {
552 unsigned int len = maxlen; 552 unsigned int len = maxlen;
553 while ( len < preCommand.length() ) { 553 while ( len < preCommand.length() ) {
554 preCommand.insert( len , "\n" ); 554 preCommand.insert( len , "\n" );
555 len += maxlen +2; 555 len += maxlen +2;
556 } 556 }
557 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) ; 557 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) ;
558 QMessageBox::information( mParent, i18n("Sync - ERROR"), 558 QMessageBox::information( mParent, i18n("Sync - ERROR"),
559 question, 559 question,
560 i18n("Okay!")) ; 560 i18n("Okay!")) ;
561 mParent->setCaption (""); 561 mParent->topLevelWidget()->setCaption ("");
562 return; 562 return;
563 } 563 }
564 mParent->setCaption ( i18n( "Copying succeed." ) ); 564 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
565 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 565 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
566 566
567 567
568 568
569 if ( syncWithFile( localTempFile, true ) ) { 569 if ( syncWithFile( localTempFile, true ) ) {
570// Event* e = mView->getLastSyncEvent(); 570// Event* e = mView->getLastSyncEvent();
571// e->setReadOnly( false ); 571// e->setReadOnly( false );
572// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 572// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
573// e->setReadOnly( true ); 573// e->setReadOnly( true );
574 if ( mWriteBackFile ) { 574 if ( mWriteBackFile ) {
575 int fi; 575 int fi;
576 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 576 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
577 QString pwd = getPassword(); 577 QString pwd = getPassword();
578 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 578 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
579 579
580 } 580 }
581 mParent->setCaption ( i18n( "Writing back file ..." ) ); 581 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
582 result = system ( postCommand ); 582 result = system ( postCommand );
583 qDebug("Writing back file result: %d ", result); 583 qDebug("Writing back file result: %d ", result);
584 if ( result != 0 ) { 584 if ( result != 0 ) {
585 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 585 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
586 return; 586 return;
587 } else { 587 } else {
588 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 588 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
589 } 589 }
590 } 590 }
591 } 591 }
592 return; 592 return;
593} 593}
594 594
595void KSyncManager::edit_sync_options() 595void KSyncManager::edit_sync_options()
596{ 596{
597 //mDialogManager->showSyncOptions(); 597 //mDialogManager->showSyncOptions();
598 //mSyncAlgoPrefs 598 //mSyncAlgoPrefs
599 QDialog dia( mParent, "dia", true ); 599 QDialog dia( mParent, "dia", true );
600 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 600 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
601 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 601 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
602 QVBoxLayout lay ( &dia ); 602 QVBoxLayout lay ( &dia );
603 lay.setSpacing( 2 ); 603 lay.setSpacing( 2 );
604 lay.setMargin( 3 ); 604 lay.setMargin( 3 );
605 lay.addWidget(&gr); 605 lay.addWidget(&gr);
606 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 606 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
607 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 607 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
608 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 608 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
609 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 609 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
610 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 610 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
611 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 611 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
612 //QRadioButton both( i18n("Take both on conflict"), &gr ); 612 //QRadioButton both( i18n("Take both on conflict"), &gr );
613 QPushButton pb ( "OK", &dia); 613 QPushButton pb ( "OK", &dia);
614 lay.addWidget( &pb ); 614 lay.addWidget( &pb );
615 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 615 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
616 switch ( mSyncAlgoPrefs ) { 616 switch ( mSyncAlgoPrefs ) {
617 case 0: 617 case 0:
618 loc.setChecked( true); 618 loc.setChecked( true);
619 break; 619 break;
620 case 1: 620 case 1:
621 rem.setChecked( true ); 621 rem.setChecked( true );
622 break; 622 break;
623 case 2: 623 case 2:
624 newest.setChecked( true); 624 newest.setChecked( true);
625 break; 625 break;
626 case 3: 626 case 3:
627 ask.setChecked( true); 627 ask.setChecked( true);
628 break; 628 break;
629 case 4: 629 case 4:
630 f_loc.setChecked( true); 630 f_loc.setChecked( true);
631 break; 631 break;
632 case 5: 632 case 5:
633 f_rem.setChecked( true); 633 f_rem.setChecked( true);
634 break; 634 break;
635 case 6: 635 case 6:
636 // both.setChecked( true); 636 // both.setChecked( true);
637 break; 637 break;
638 default: 638 default:
639 break; 639 break;
640 } 640 }
641 if ( dia.exec() ) { 641 if ( dia.exec() ) {
642 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 642 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
643 } 643 }
644 644
645 645
646} 646}
647QString KSyncManager::getPassword( ) 647QString KSyncManager::getPassword( )
648{ 648{
649 QString retfile = ""; 649 QString retfile = "";
650 QDialog dia ( mParent, "input-dialog", true ); 650 QDialog dia ( mParent, "input-dialog", true );
651 QLineEdit lab ( &dia ); 651 QLineEdit lab ( &dia );
652 lab.setEchoMode( QLineEdit::Password ); 652 lab.setEchoMode( QLineEdit::Password );
653 QVBoxLayout lay( &dia ); 653 QVBoxLayout lay( &dia );
654 lay.setMargin(7); 654 lay.setMargin(7);
655 lay.setSpacing(7); 655 lay.setSpacing(7);
656 lay.addWidget( &lab); 656 lay.addWidget( &lab);
657 dia.setFixedSize( 230,50 ); 657 dia.setFixedSize( 230,50 );
658 dia.setCaption( i18n("Enter password") ); 658 dia.setCaption( i18n("Enter password") );
659 QPushButton pb ( "OK", &dia); 659 QPushButton pb ( "OK", &dia);
660 lay.addWidget( &pb ); 660 lay.addWidget( &pb );
661 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 661 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
662 dia.show(); 662 dia.show();
663 int res = dia.exec(); 663 int res = dia.exec();
664 if ( res ) 664 if ( res )
665 retfile = lab.text(); 665 retfile = lab.text();
666 dia.hide(); 666 dia.hide();
667 qApp->processEvents(); 667 qApp->processEvents();
668 return retfile; 668 return retfile;
669 669
670} 670}
671 671
672 672
673void KSyncManager::confSync() 673void KSyncManager::confSync()
674{ 674{
675 static KSyncPrefsDialog* sp = 0; 675 static KSyncPrefsDialog* sp = 0;
676 if ( ! sp ) { 676 if ( ! sp ) {
677 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 677 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
678 } 678 }
679 sp->usrReadConfig(); 679 sp->usrReadConfig();
680#ifndef DESKTOP_VERSION 680#ifndef DESKTOP_VERSION
681 sp->showMaximized(); 681 sp->showMaximized();
682#else 682#else
683 sp->show(); 683 sp->show();
684#endif 684#endif
685 sp->exec(); 685 sp->exec();
686 mSyncProfileNames = sp->getSyncProfileNames(); 686 mSyncProfileNames = sp->getSyncProfileNames();
687 mLocalMachineName = sp->getLocalMachineName (); 687 mLocalMachineName = sp->getLocalMachineName ();
688 fillSyncMenu(); 688 fillSyncMenu();
689} 689}
690 690
691void KSyncManager::syncSharp() 691void KSyncManager::syncSharp()
692{ 692{
693 if ( ! syncExternalApplication("sharp") ) 693 if ( ! syncExternalApplication("sharp") )
694 qDebug("ERROR sync sharp ");; 694 qDebug("ERROR sync sharp ");;
695} 695}
696 696
697bool KSyncManager::syncExternalApplication(QString resource) 697bool KSyncManager::syncExternalApplication(QString resource)
698{ 698{
699 699
700 emit save(); 700 emit save();
701 701
702 if ( mAskForPreferences ) 702 if ( mAskForPreferences )
703 edit_sync_options(); 703 edit_sync_options();
704 704
705 qDebug("sync %s", resource.latin1()); 705 qDebug("sync %s", resource.latin1());
706 706
707 bool syncOK = mImplementation->syncExternal(this, resource); 707 bool syncOK = mImplementation->syncExternal(this, resource);
708 708
709 return syncOK; 709 return syncOK;
710 710
711} 711}
712 712
713void KSyncManager::syncPhone() 713void KSyncManager::syncPhone()
714{ 714{
715 emit save(); 715 emit save();
716 716
717 qDebug("pending syncPhone(); "); 717 qDebug("pending syncPhone(); ");
718 //mView->syncPhone(); 718 //mView->syncPhone();
719 719
720} 720}
721 721
722void KSyncManager::showProgressBar(int percentage, QString caption, int total) 722void KSyncManager::showProgressBar(int percentage, QString caption, int total)
723{ 723{
724 if (!bar->isVisible()) 724 if (!bar->isVisible())
725 { 725 {
726 bar->setCaption (caption); 726 bar->setCaption (caption);
727 bar->setTotalSteps ( total ) ; 727 bar->setTotalSteps ( total ) ;
728 728
729 bar->show(); 729 bar->show();
730 } 730 }
731 731
732 bar->setProgress( percentage ); 732 bar->setProgress( percentage );
733} 733}
734 734
735void KSyncManager::hideProgressBar() 735void KSyncManager::hideProgressBar()
736{ 736{
737 bar->hide(); 737 bar->hide();
738} 738}
739 739
740bool KSyncManager::isProgressBarCanceled() 740bool KSyncManager::isProgressBarCanceled()
741{ 741{
742 return !bar->isVisible(); 742 return !bar->isVisible();
743} 743}
744 744
745QString KSyncManager::syncFileName() 745QString KSyncManager::syncFileName()
746{ 746{
747 747
748 QString fn = "tempfile"; 748 QString fn = "tempfile";
749 switch(mTargetApp) 749 switch(mTargetApp)
750 { 750 {
751 case (KAPI): 751 case (KAPI):
752 fn = "addressbook.vcf"; 752 fn = "tempsyncab.vcf";
753 break; 753 break;
754 case (KOPI): 754 case (KOPI):
755 fn = "synccalendar.ics"; 755 fn = "tempsynccal.ics";
756 break; 756 break;
757 case (PWMPI): 757 case (PWMPI):
758 fn = "manager.pwm"; 758 fn = "tempsyncpw.pwm";
759 break; 759 break;
760 default: 760 default:
761 break; 761 break;
762 } 762 }
763#ifdef _WIN32_ 763#ifdef _WIN32_
764 return locateLocal( "tmp", fn ); 764 return locateLocal( "tmp", fn );
765#else 765#else
766 return (QString( "/tmp/" )+ fn ); 766 return (QString( "/tmp/" )+ fn );
767#endif 767#endif
768} 768}
769 769
770void KSyncManager::syncPi() 770void KSyncManager::syncPi()
771{ 771{
772 qApp->processEvents(); 772 qApp->processEvents();
773 bool ok; 773 bool ok;
774 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 774 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
775 if ( ! ok ) { 775 if ( ! ok ) {
776 mParent->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 776 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
777 return; 777 return;
778 } 778 }
779 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 779 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
780 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 780 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
781 mParent->setCaption( i18n("Sending request for remote file ...") ); 781 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
782 commandSocket->readFile( syncFileName() ); 782 commandSocket->readFile( syncFileName() );
783} 783}
784 784
785void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 785void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
786{ 786{
787 qDebug("MainWindow::deleteCommandSocket %d", state); 787 qDebug("MainWindow::deleteCommandSocket %d", state);
788 788
789 //enum { success, errorW, errorR, quiet }; 789 //enum { success, errorW, errorR, quiet };
790 if ( state == KCommandSocket::errorR ) { 790 if ( state == KCommandSocket::errorR ) {
791 mParent->setCaption( i18n("ERROR: Receiving remote file failed.") ); 791 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
792 delete s; 792 delete s;
793 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 793 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
794 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 794 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
795 commandSocket->sendStop(); 795 commandSocket->sendStop();
796 return; 796 return;
797 797
798 } else if ( state == KCommandSocket::errorW ) { 798 } else if ( state == KCommandSocket::errorW ) {
799 mParent->setCaption( i18n("ERROR:Writing back file failed.") ); 799 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
800 800
801 } else if ( state == KCommandSocket::successR ) { 801 } else if ( state == KCommandSocket::successR ) {
802 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 802 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
803 803
804 } else if ( state == KCommandSocket::successW ) { 804 } else if ( state == KCommandSocket::successW ) {
805 mParent->setCaption( i18n("Pi-Sync succesful!") ); 805 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
806 } 806 }
807 807
808 delete s; 808 delete s;
809} 809}
810 810
811void KSyncManager::readFileFromSocket() 811void KSyncManager::readFileFromSocket()
812{ 812{
813 QString fileName = syncFileName(); 813 QString fileName = syncFileName();
814 mParent->setCaption( i18n("Remote file saved to temp file.") ); 814 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
815 if ( ! syncWithFile( fileName , true ) ) { 815 if ( ! syncWithFile( fileName , true ) ) {
816 mParent->setCaption( i18n("Syncing failed.") ); 816 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
817 qDebug("Syncing failed "); 817 qDebug("Syncing failed ");
818 return; 818 return;
819 } 819 }
820 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 820 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
821 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 821 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
822 if ( mWriteBackFile ) 822 if ( mWriteBackFile )
823 commandSocket->writeFile( fileName ); 823 commandSocket->writeFile( fileName );
824 else { 824 else {
825 commandSocket->sendStop(); 825 commandSocket->sendStop();
826 mParent->setCaption( i18n("Pi-Sync succesful!") ); 826 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
827 } 827 }
828} 828}
829 829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 830KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
853{ 831{
854 mPassWord = pw; 832 mPassWord = pw;
855 mSocket = 0; 833 mSocket = 0;
856 mSyncActionDialog = 0; 834 mSyncActionDialog = 0;
857 blockRC = false; 835 blockRC = false;
858}; 836};
859 837
860void KServerSocket::newConnection ( int socket ) 838void KServerSocket::newConnection ( int socket )
861{ 839{
862 // qDebug("KServerSocket:New connection %d ", socket); 840 // qDebug("KServerSocket:New connection %d ", socket);
863 if ( mSocket ) { 841 if ( mSocket ) {
864 qDebug("KServerSocket::newConnection Socket deleted! "); 842 qDebug("KServerSocket::newConnection Socket deleted! ");
865 delete mSocket; 843 delete mSocket;
866 mSocket = 0; 844 mSocket = 0;
867 } 845 }
868 mSocket = new QSocket( this ); 846 mSocket = new QSocket( this );
869 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 847 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
870 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 848 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
871 mSocket->setSocket( socket ); 849 mSocket->setSocket( socket );
872} 850}
873 851
874void KServerSocket::discardClient() 852void KServerSocket::discardClient()
875{ 853{
876 //qDebug(" KServerSocket::discardClient()"); 854 //qDebug(" KServerSocket::discardClient()");
877 if ( mSocket ) { 855 if ( mSocket ) {
878 delete mSocket; 856 delete mSocket;
879 mSocket = 0; 857 mSocket = 0;
880 } 858 }
881 //emit endConnect(); 859 //emit endConnect();
882} 860}
883void KServerSocket::readClient() 861void KServerSocket::readClient()
884{ 862{
885 if ( blockRC ) 863 if ( blockRC )
886 return; 864 return;
887 if ( mSocket == 0 ) { 865 if ( mSocket == 0 ) {
888 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 866 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
889 return; 867 return;
890 } 868 }
891 qDebug("KServerSocket readClient()"); 869 qDebug("KServerSocket readClient()");
892 if ( mSocket->canReadLine() ) { 870 if ( mSocket->canReadLine() ) {
893 QString line = mSocket->readLine(); 871 QString line = mSocket->readLine();
894 qDebug("KServerSocket readline: %s ", line.latin1()); 872 qDebug("KServerSocket readline: %s ", line.latin1());
895 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 873 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
896 if ( tokens[0] == "GET" ) { 874 if ( tokens[0] == "GET" ) {
897 if ( tokens[1] == mPassWord ) 875 if ( tokens[1] == mPassWord )
898 //emit sendFile( mSocket ); 876 //emit sendFile( mSocket );
899 send_file(); 877 send_file();
900 else { 878 else {
901 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 879 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
902 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 880 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
903 } 881 }
904 } 882 }
905 if ( tokens[0] == "PUT" ) { 883 if ( tokens[0] == "PUT" ) {
906 if ( tokens[1] == mPassWord ) { 884 if ( tokens[1] == mPassWord ) {
907 //emit getFile( mSocket ); 885 //emit getFile( mSocket );
908 blockRC = true; 886 blockRC = true;
909 get_file(); 887 get_file();
910 } 888 }
911 else { 889 else {
912 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 890 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
913 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 891 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
914 } 892 }
915 } 893 }
916 if ( tokens[0] == "STOP" ) { 894 if ( tokens[0] == "STOP" ) {
917 //emit endConnect(); 895 //emit endConnect();
918 end_connect(); 896 end_connect();
919 } 897 }
920 } 898 }
921} 899}
922void KServerSocket::end_connect() 900void KServerSocket::end_connect()
923{ 901{
924 delete mSyncActionDialog; 902 delete mSyncActionDialog;
925 mSyncActionDialog = 0; 903 mSyncActionDialog = 0;
926} 904}
927void KServerSocket::send_file() 905void KServerSocket::send_file()
928{ 906{
929 //qDebug("MainWindow::sendFile(QSocket* s) "); 907 //qDebug("MainWindow::sendFile(QSocket* s) ");
930 if ( mSyncActionDialog ) 908 if ( mSyncActionDialog )
931 delete mSyncActionDialog; 909 delete mSyncActionDialog;
932 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 910 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
933 mSyncActionDialog->setCaption(i18n("Received sync request")); 911 mSyncActionDialog->setCaption(i18n("Received sync request"));
934 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 912 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
935 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 913 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
936 lay->addWidget( label); 914 lay->addWidget( label);
937 lay->setMargin(7); 915 lay->setMargin(7);
938 lay->setSpacing(7); 916 lay->setSpacing(7);
939 mSyncActionDialog->setFixedSize( 230, 120); 917 mSyncActionDialog->setFixedSize( 230, 120);
940 mSyncActionDialog->show(); 918 mSyncActionDialog->show();
919 mSyncActionDialog->raise();
941 qDebug("KSS::saving ... "); 920 qDebug("KSS::saving ... ");
942 emit request_file(); 921 emit request_file();
943 qApp->processEvents(); 922 qApp->processEvents();
944 QString fileName = mFileName; 923 QString fileName = mFileName;
945 QFile file( fileName ); 924 QFile file( fileName );
946 if (!file.open( IO_ReadOnly ) ) { 925 if (!file.open( IO_ReadOnly ) ) {
947 delete mSyncActionDialog; 926 delete mSyncActionDialog;
948 mSyncActionDialog = 0; 927 mSyncActionDialog = 0;
949 qDebug("KSS::error open file "); 928 qDebug("KSS::error open file ");
950 mSocket->close(); 929 mSocket->close();
951 if ( mSocket->state() == QSocket::Idle ) 930 if ( mSocket->state() == QSocket::Idle )
952 QTimer::singleShot( 10, this , SLOT ( discardClient())); 931 QTimer::singleShot( 10, this , SLOT ( discardClient()));
953 return ; 932 return ;
954 933
955 } 934 }
956 mSyncActionDialog->setCaption( i18n("Sending file...") ); 935 mSyncActionDialog->setCaption( i18n("Sending file...") );
957 QTextStream ts( &file ); 936 QTextStream ts( &file );
958 ts.setCodec( QTextCodec::codecForName("utf8") ); 937 ts.setCodec( QTextCodec::codecForName("utf8") );
959 QTextStream os( mSocket ); 938 QTextStream os( mSocket );
960 os.setCodec( QTextCodec::codecForName("utf8") ); 939 os.setCodec( QTextCodec::codecForName("utf8") );
961 //os.setEncoding( QTextStream::UnicodeUTF8 ); 940 //os.setEncoding( QTextStream::UnicodeUTF8 );
962 while ( ! ts.atEnd() ) { 941 while ( ! ts.atEnd() ) {
963 os << ts.readLine() << "\n"; 942 os << ts.readLine() << "\n";
964 } 943 }
965 //os << ts.read(); 944 //os << ts.read();
966 file.close(); 945 file.close();
967 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 946 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
968 mSocket->close(); 947 mSocket->close();
969 if ( mSocket->state() == QSocket::Idle ) 948 if ( mSocket->state() == QSocket::Idle )
970 QTimer::singleShot( 10, this , SLOT ( discardClient())); 949 QTimer::singleShot( 10, this , SLOT ( discardClient()));
971} 950}
972void KServerSocket::get_file() 951void KServerSocket::get_file()
973{ 952{
974 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 953 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
975 954
976 piTime.start(); 955 piTime.start();
977 piFileString = ""; 956 piFileString = "";
978 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 957 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
979} 958}
980 959
981 960
982void KServerSocket::readBackFileFromSocket() 961void KServerSocket::readBackFileFromSocket()
983{ 962{
984 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 963 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
985 while ( mSocket->canReadLine () ) { 964 while ( mSocket->canReadLine () ) {
986 piTime.restart(); 965 piTime.restart();
987 QString line = mSocket->readLine (); 966 QString line = mSocket->readLine ();
988 piFileString += line; 967 piFileString += line;
989 //qDebug("readline: %s ", line.latin1()); 968 //qDebug("readline: %s ", line.latin1());
990 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 969 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
991 970
992 } 971 }
993 if ( piTime.elapsed () < 3000 ) { 972 if ( piTime.elapsed () < 3000 ) {
994 // wait for more 973 // wait for more
995 //qDebug("waitformore "); 974 //qDebug("waitformore ");
996 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 975 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
997 return; 976 return;
998 } 977 }
999 QString fileName = mFileName; 978 QString fileName = mFileName;
1000 QFile file ( fileName ); 979 QFile file ( fileName );
1001 if (!file.open( IO_WriteOnly ) ) { 980 if (!file.open( IO_WriteOnly ) ) {
1002 delete mSyncActionDialog; 981 delete mSyncActionDialog;
1003 mSyncActionDialog = 0; 982 mSyncActionDialog = 0;
1004 qDebug("error open cal file "); 983 qDebug("error open cal file ");
1005 piFileString = ""; 984 piFileString = "";
1006 emit file_received( false ); 985 emit file_received( false );
1007 blockRC = false; 986 blockRC = false;
1008 return ; 987 return ;
1009 988
1010 } 989 }
1011 990
1012 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 991 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1013 QTextStream ts ( &file ); 992 QTextStream ts ( &file );
1014 ts.setCodec( QTextCodec::codecForName("utf8") ); 993 ts.setCodec( QTextCodec::codecForName("utf8") );
1015 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 994 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1016 ts << piFileString; 995 ts << piFileString;
1017 mSocket->close(); 996 mSocket->close();
1018 if ( mSocket->state() == QSocket::Idle ) 997 if ( mSocket->state() == QSocket::Idle )
1019 QTimer::singleShot( 10, this , SLOT ( discardClient())); 998 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1020 file.close(); 999 file.close();
1021 delete mSyncActionDialog; 1000 delete mSyncActionDialog;
1022 mSyncActionDialog = 0; 1001 mSyncActionDialog = 0;
1023 piFileString = ""; 1002 piFileString = "";
1024 blockRC = false; 1003 blockRC = false;
1025 emit file_received( true ); 1004 emit file_received( true );
1026 1005
1027} 1006}
1028 1007
1029KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1008KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1030{ 1009{
1031 mPassWord = password; 1010 mPassWord = password;
1032 mSocket = 0; 1011 mSocket = 0;
1033 mPort = port; 1012 mPort = port;
1034 mHost = host; 1013 mHost = host;
1035 1014
1036 mRetVal = quiet; 1015 mRetVal = quiet;
1037 mTimerSocket = new QTimer ( this ); 1016 mTimerSocket = new QTimer ( this );
1038 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1017 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1039} 1018}
1040void KCommandSocket::readFile( QString fn ) 1019void KCommandSocket::readFile( QString fn )
1041{ 1020{
1042 if ( !mSocket ) { 1021 if ( !mSocket ) {
1043 mSocket = new QSocket( this ); 1022 mSocket = new QSocket( this );
1044 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1023 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1045 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1024 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1046 } 1025 }
1047 mFileString = ""; 1026 mFileString = "";
1048 mFileName = fn; 1027 mFileName = fn;
1049 mFirst = true; 1028 mFirst = true;
1050 mSocket->connectToHost( mHost, mPort ); 1029 mSocket->connectToHost( mHost, mPort );
1051 QTextStream os( mSocket ); 1030 QTextStream os( mSocket );
1052 os.setEncoding( QTextStream::UnicodeUTF8 ); 1031 os.setEncoding( QTextStream::UnicodeUTF8 );
1053 os << "GET " << mPassWord << "\r\n"; 1032 os << "GET " << mPassWord << "\r\n";
1054 mTimerSocket->start( 10000 ); 1033 mTimerSocket->start( 10000 );
1055} 1034}
1056 1035
1057void KCommandSocket::writeFile( QString fileName ) 1036void KCommandSocket::writeFile( QString fileName )
1058{ 1037{
1059 if ( !mSocket ) { 1038 if ( !mSocket ) {
1060 mSocket = new QSocket( this ); 1039 mSocket = new QSocket( this );
1061 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1040 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1062 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1041 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1063 } 1042 }
1064 mFileName = fileName ; 1043 mFileName = fileName ;
1065 mSocket->connectToHost( mHost, mPort ); 1044 mSocket->connectToHost( mHost, mPort );
1066} 1045}
1067void KCommandSocket::writeFileToSocket() 1046void KCommandSocket::writeFileToSocket()
1068{ 1047{
1069 QFile file2( mFileName ); 1048 QFile file2( mFileName );
1070 if (!file2.open( IO_ReadOnly ) ) { 1049 if (!file2.open( IO_ReadOnly ) ) {
1071 mRetVal= errorW; 1050 mRetVal= errorW;
1072 mSocket->close(); 1051 mSocket->close();
1073 if ( mSocket->state() == QSocket::Idle ) 1052 if ( mSocket->state() == QSocket::Idle )
1074 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1053 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1075 return ; 1054 return ;
1076 } 1055 }
1077 QTextStream ts2( &file2 ); 1056 QTextStream ts2( &file2 );
1078 ts2.setCodec( QTextCodec::codecForName("utf8") ); 1057 ts2.setCodec( QTextCodec::codecForName("utf8") );
1079 QTextStream os2( mSocket ); 1058 QTextStream os2( mSocket );
1080 os2.setCodec( QTextCodec::codecForName("utf8") ); 1059 os2.setCodec( QTextCodec::codecForName("utf8") );
1081 os2 << "PUT " << mPassWord << "\r\n";; 1060 os2 << "PUT " << mPassWord << "\r\n";;
1082 while ( ! ts2.atEnd() ) { 1061 while ( ! ts2.atEnd() ) {
1083 os2 << ts2.readLine() << "\n"; 1062 os2 << ts2.readLine() << "\n";
1084 } 1063 }
1085 mRetVal= successW; 1064 mRetVal= successW;
1086 file2.close(); 1065 file2.close();
1087 mSocket->close(); 1066 mSocket->close();
1088 if ( mSocket->state() == QSocket::Idle ) 1067 if ( mSocket->state() == QSocket::Idle )
1089 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1068 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1090} 1069}
1091void KCommandSocket::sendStop() 1070void KCommandSocket::sendStop()
1092{ 1071{
1093 if ( !mSocket ) { 1072 if ( !mSocket ) {
1094 mSocket = new QSocket( this ); 1073 mSocket = new QSocket( this );
1095 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1074 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1096 } 1075 }
1097 mSocket->connectToHost( mHost, mPort ); 1076 mSocket->connectToHost( mHost, mPort );
1098 QTextStream os2( mSocket ); 1077 QTextStream os2( mSocket );
1099 os2.setCodec( QTextCodec::codecForName("utf8") ); 1078 os2.setCodec( QTextCodec::codecForName("utf8") );
1100 os2 << "STOP\r\n"; 1079 os2 << "STOP\r\n";
1101 mSocket->close(); 1080 mSocket->close();
1102 if ( mSocket->state() == QSocket::Idle ) 1081 if ( mSocket->state() == QSocket::Idle )
1103 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1082 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1104} 1083}
1105 1084
1106void KCommandSocket::startReadFileFromSocket() 1085void KCommandSocket::startReadFileFromSocket()
1107{ 1086{
1108 if ( ! mFirst ) 1087 if ( ! mFirst )
1109 return; 1088 return;
1110 mFirst = false; 1089 mFirst = false;
1111 mTimerSocket->stop(); 1090 mTimerSocket->stop();
1112 mFileString = ""; 1091 mFileString = "";
1113 mTime.start(); 1092 mTime.start();
1114 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1093 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1115 1094
1116} 1095}
1117void KCommandSocket::readFileFromSocket() 1096void KCommandSocket::readFileFromSocket()
1118{ 1097{
1119 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1098 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1120 while ( mSocket->canReadLine () ) { 1099 while ( mSocket->canReadLine () ) {
1121 mTime.restart(); 1100 mTime.restart();
1122 QString line = mSocket->readLine (); 1101 QString line = mSocket->readLine ();
1123 mFileString += line; 1102 mFileString += line;
1124 //qDebug("readline: %s ", line.latin1()); 1103 //qDebug("readline: %s ", line.latin1());
1125 } 1104 }
1126 if ( mTime.elapsed () < 3000 ) { 1105 if ( mTime.elapsed () < 3000 ) {
1127 // wait for more 1106 // wait for more
1128 //qDebug("waitformore "); 1107 //qDebug("waitformore ");
1129 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1108 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1130 return; 1109 return;
1131 } 1110 }
1132 QString fileName = mFileName; 1111 QString fileName = mFileName;
1133 QFile file ( fileName ); 1112 QFile file ( fileName );
1134 if (!file.open( IO_WriteOnly ) ) { 1113 if (!file.open( IO_WriteOnly ) ) {
1135 mFileString = ""; 1114 mFileString = "";
1136 mRetVal = errorR; 1115 mRetVal = errorR;
1137 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 1116 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
1138 deleteSocket(); 1117 deleteSocket();
1139 return ; 1118 return ;
1140 1119
1141 } 1120 }
1142 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1121 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1143 QTextStream ts ( &file ); 1122 QTextStream ts ( &file );
1144 ts.setCodec( QTextCodec::codecForName("utf8") ); 1123 ts.setCodec( QTextCodec::codecForName("utf8") );
1145 ts << mFileString; 1124 ts << mFileString;
1146 file.close(); 1125 file.close();
1147 mFileString = ""; 1126 mFileString = "";
1148 mRetVal = successR; 1127 mRetVal = successR;
1149 mSocket->close(); 1128 mSocket->close();
1150 // if state is not idle, deleteSocket(); is called via 1129 // if state is not idle, deleteSocket(); is called via
1151 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1130 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1152 if ( mSocket->state() == QSocket::Idle ) 1131 if ( mSocket->state() == QSocket::Idle )
1153 deleteSocket(); 1132 deleteSocket();
1154} 1133}
1155 1134
1156void KCommandSocket::deleteSocket() 1135void KCommandSocket::deleteSocket()
1157{ 1136{
1158 if ( mTimerSocket->isActive () ) { 1137 if ( mTimerSocket->isActive () ) {
1159 mTimerSocket->stop(); 1138 mTimerSocket->stop();
1160 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1139 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1161 mRetVal = errorR; 1140 mRetVal = errorR;
1162 } 1141 }
1163 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1142 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1164 if ( mSocket) 1143 if ( mSocket)
1165 delete mSocket; 1144 delete mSocket;
1166 mSocket = 0; 1145 mSocket = 0;
1167 emit commandFinished( this, mRetVal ); 1146 emit commandFinished( this, mRetVal );
1168} 1147}
1169 1148
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 0eb3323..aad48d9 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,227 +1,227 @@
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> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 51
52signals: 52signals:
53 void file_received( bool ); 53 void file_received( bool );
54 void request_file(); 54 void request_file();
55 void saveFile(); 55 void saveFile();
56 void endConnect(); 56 void endConnect();
57private slots: 57private slots:
58 void discardClient(); 58 void discardClient();
59 void readClient(); 59 void readClient();
60 void readBackFileFromSocket(); 60 void readBackFileFromSocket();
61 private : 61 private :
62 bool blockRC; 62 bool blockRC;
63 void send_file(); 63 void send_file();
64 void get_file(); 64 void get_file();
65 void end_connect(); 65 void end_connect();
66 QDialog* mSyncActionDialog; 66 QDialog* mSyncActionDialog;
67 QSocket* mSocket; 67 QSocket* mSocket;
68 QString mPassWord; 68 QString mPassWord;
69 QString mFileName; 69 QString mFileName;
70 QTime piTime; 70 QTime piTime;
71 QString piFileString; 71 QString piFileString;
72}; 72};
73 73
74class KCommandSocket : public QObject 74class KCommandSocket : public QObject
75{ 75{
76 Q_OBJECT 76 Q_OBJECT
77public: 77public:
78 enum state { successR, errorR, successW, errorW, quiet }; 78 enum state { successR, errorR, successW, errorW, quiet };
79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
80 void readFile( QString ); 80 void readFile( QString );
81 void writeFile( QString ); 81 void writeFile( QString );
82 void sendStop(); 82 void sendStop();
83 83
84 84
85signals: 85signals:
86 void commandFinished( KCommandSocket*, int ); 86 void commandFinished( KCommandSocket*, int );
87private slots: 87private slots:
88 void startReadFileFromSocket(); 88 void startReadFileFromSocket();
89 void readFileFromSocket(); 89 void readFileFromSocket();
90 void deleteSocket(); 90 void deleteSocket();
91 void writeFileToSocket(); 91 void writeFileToSocket();
92 private : 92 private :
93 QSocket* mSocket; 93 QSocket* mSocket;
94 QString mPassWord; 94 QString mPassWord;
95 Q_UINT16 mPort; 95 Q_UINT16 mPort;
96 QString mHost; 96 QString mHost;
97 QString mFileName; 97 QString mFileName;
98 QTimer* mTimerSocket; 98 QTimer* mTimerSocket;
99 int mRetVal; 99 int mRetVal;
100 QTime mTime; 100 QTime mTime;
101 QString mFileString; 101 QString mFileString;
102 bool mFirst; 102 bool mFirst;
103}; 103};
104 104
105 105
106class KSyncManager : public QObject 106class KSyncManager : public QObject
107{ 107{
108 Q_OBJECT 108 Q_OBJECT
109 109
110 public: 110 public:
111 enum TargetApp { 111 enum TargetApp {
112 KOPI = 0, 112 KOPI = 0,
113 KAPI = 1, 113 KAPI = 1,
114 PWMPI = 2 }; 114 PWMPI = 2 };
115 115
116 116
117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
118 ~KSyncManager() ; 118 ~KSyncManager() ;
119 119
120 bool blockSave() { return mBlockSaveFlag; } 120 bool blockSave() { return mBlockSaveFlag; }
121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
122 void setDefaultFileName( QString s) { mDefFileName = s ;} 122 void setDefaultFileName( QString s) { mDefFileName = s ;}
123 QString defaultFileName() { return mDefFileName ;} 123 QString defaultFileName() { return mDefFileName ;}
124 QString syncFileName(); 124 QString syncFileName();
125 void fillSyncMenu(); 125 void fillSyncMenu();
126 126
127 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 127 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
128 QString getCurrentSyncName() { return mCurrentSyncName; } 128 QString getCurrentSyncName() { return mCurrentSyncName; }
129 129
130 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 130 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
131 void hideProgressBar(); 131 void hideProgressBar();
132 bool isProgressBarCanceled(); 132 bool isProgressBarCanceled();
133 133
134 // sync stuff 134 // sync stuff
135 QString mLocalMachineName; 135 QString mLocalMachineName;
136 QStringList mExternSyncProfiles; 136 QStringList mExternSyncProfiles;
137 QStringList mSyncProfileNames; 137 QStringList mSyncProfileNames;
138 bool mAskForPreferences; 138 bool mAskForPreferences;
139 bool mShowSyncSummary; 139 bool mShowSyncSummary;
140 bool mShowSyncEvents; 140 bool mShowSyncEvents;
141 bool mShowTodoInAgenda; 141 bool mShowTodoInAgenda;
142 bool mWriteBackExistingOnly; 142 bool mWriteBackExistingOnly;
143 int mSyncAlgoPrefs; 143 int mSyncAlgoPrefs;
144 int mRingSyncAlgoPrefs; 144 int mRingSyncAlgoPrefs;
145 bool mWriteBackFile; 145 bool mWriteBackFile;
146 int mWriteBackInFuture; 146 int mWriteBackInFuture;
147 QString mPhoneDevice; 147 QString mPhoneDevice;
148 QString mPhoneConnection; 148 QString mPhoneConnection;
149 QString mPhoneModel; 149 QString mPhoneModel;
150 QString mLastSyncedLocalFile; // save! 150 QString mLastSyncedLocalFile; // save!
151 QString mPassWordPiSync; 151 QString mPassWordPiSync;
152 QString mActiveSyncPort; 152 QString mActiveSyncPort;
153 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
154 154
155 signals: 155 signals:
156 void save(); 156 void save();
157 void request_file(); 157 void request_file();
158 void getFile( bool ); 158 void getFile( bool );
159 159
160 public slots: 160 public slots:
161 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
162 void deleteCommandSocket(KCommandSocket*s, int state);
163 void readFileFromSocket();
162 164
163 private: 165 private:
164 // LR ******************************* 166 // LR *******************************
165 // sync stuff! 167 // sync stuff!
166 void syncPi(); 168 void syncPi();
167 void deleteCommandSocket(KCommandSocket*s, int state);
168 void readFileFromSocket();
169 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
170 void enableQuick(); 170 void enableQuick();
171 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
172 QString mDefFileName; 172 QString mDefFileName;
173 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;
174 QString mCurrentSyncName; 174 QString mCurrentSyncName;
175 void quickSyncLocalFile(); 175 void quickSyncLocalFile();
176 bool syncWithFile( QString fn , bool quick ); 176 bool syncWithFile( QString fn , bool quick );
177 void syncLocalFile(); 177 void syncLocalFile();
178 void syncPhone(); 178 void syncPhone();
179 void syncSharp(); 179 void syncSharp();
180 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
181 void multiSync( bool askforPrefs ); 181 void multiSync( bool askforPrefs );
182 int mCurrentSyncProfile ; 182 int mCurrentSyncProfile ;
183 void syncRemote( KSyncProfile* prof, bool ask = true); 183 void syncRemote( KSyncProfile* prof, bool ask = true);
184 void edit_sync_options(); 184 void edit_sync_options();
185 int ringSync(); 185 int ringSync();
186 QString getPassword( ); 186 QString getPassword( );
187 187
188 private slots: 188 private slots:
189 void confSync(); 189 void confSync();
190 // ********************* 190 // *********************
191 191
192 private: 192 private:
193 bool mBlockSaveFlag; 193 bool mBlockSaveFlag;
194 194
195 195
196 QWidget* mParent; 196 QWidget* mParent;
197 KSyncInterface* mImplementation; 197 KSyncInterface* mImplementation;
198 TargetApp mTargetApp; 198 TargetApp mTargetApp;
199 QPopupMenu* mSyncMenu; 199 QPopupMenu* mSyncMenu;
200 200
201 QProgressBar* bar; 201 QProgressBar* bar;
202 202
203 203
204 204
205 205
206 206
207}; 207};
208 208
209 209
210class KSyncInterface 210class KSyncInterface
211{ 211{
212 212
213 213
214 public : 214 public :
215 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 215 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
216 216
217 virtual bool syncExternal(KSyncManager* manager, QString resource) 217 virtual bool syncExternal(KSyncManager* manager, QString resource)
218 { 218 {
219 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. 219 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
220 return false; 220 return false;
221 } 221 }
222 222
223 223
224}; 224};
225 225
226 226
227#endif 227#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 0caa27e..ee092b9 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,732 +1,732 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@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 <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46 46
47#include <kcolorbutton.h> 47#include <kcolorbutton.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <klocale.h> 49#include <klocale.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <kfontdialog.h> 51#include <kfontdialog.h>
52#include <kmessagebox.h> 52#include <kmessagebox.h>
53#include <kcolordialog.h> 53#include <kcolordialog.h>
54#include <kiconloader.h> 54#include <kiconloader.h>
55#include <kemailsettings.h> 55#include <kemailsettings.h>
56#include <kstandarddirs.h> 56#include <kstandarddirs.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58#include <kmessagebox.h> 58#include <kmessagebox.h>
59 59
60//#include <kurlrequester.h> 60//#include <kurlrequester.h>
61#include <klineedit.h> 61#include <klineedit.h>
62#include "ksyncprofile.h" 62#include "ksyncprofile.h"
63 63
64 64
65//#include "koprefs.h" 65//#include "koprefs.h"
66 66
67#include "ksyncprefsdialog.h" 67#include "ksyncprefsdialog.h"
68//#include "koglobals.h" 68//#include "koglobals.h"
69 69
70 70
71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
72 KDialog(parent,name,true) 72 KDialog(parent,name,true)
73{ 73{
74 74
75 setCaption( i18n("Synchronization Preferences")); 75 setCaption( i18n("Synchronization Preferences"));
76 76
77 mSyncProfiles.setAutoDelete( true ); 77 mSyncProfiles.setAutoDelete( true );
78 setupSyncAlgTab(); 78 setupSyncAlgTab();
79} 79}
80 80
81 81
82KSyncPrefsDialog::~KSyncPrefsDialog() 82KSyncPrefsDialog::~KSyncPrefsDialog()
83{ 83{
84} 84}
85 85
86void KSyncPrefsDialog::setupSyncAlgTab() 86void KSyncPrefsDialog::setupSyncAlgTab()
87{ 87{
88 QLabel * lab; 88 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
95 95
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
109 109
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 113 //++iii;
114 114
115 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 119 ++iii;
120 120
121 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 126
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 129
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 132
133 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
138 138
139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
140 topLayout->addWidget(lab ,iii,0); 140 topLayout->addWidget(lab ,iii,0);
141 topLayout->addWidget(mProfileBox, iii,1); 141 topLayout->addWidget(mProfileBox, iii,1);
142 ++iii; 142 ++iii;
143 143
144 mIncludeInRing = new QCheckBox( i18n("Include in multiple calendar sync"), topFrame ); 144 mIncludeInRing = new QCheckBox( i18n("Include in multiple calendar sync"), topFrame );
145 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 145 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
146 ++iii; 146 ++iii;
147 mIncludeInRingAB = new QCheckBox( i18n("Include in multiple addressbook sync"), topFrame ); 147 mIncludeInRingAB = new QCheckBox( i18n("Include in multiple addressbook sync"), topFrame );
148 topLayout->addMultiCellWidget(mIncludeInRingAB, iii,iii,0,1); 148 topLayout->addMultiCellWidget(mIncludeInRingAB, iii,iii,0,1);
149 ++iii; 149 ++iii;
150 mIncludeInRingPWM = new QCheckBox( i18n("Include in multiple pwmanager sync"), topFrame ); 150 mIncludeInRingPWM = new QCheckBox( i18n("Include in multiple pwmanager sync"), topFrame );
151 topLayout->addMultiCellWidget(mIncludeInRingPWM, iii,iii,0,1); 151 topLayout->addMultiCellWidget(mIncludeInRingPWM, iii,iii,0,1);
152 ++iii; 152 ++iii;
153 153
154 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 154 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
155 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 155 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
156 ++iii; 156 ++iii;
157 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 157 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
158 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 158 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
159 ++iii; 159 ++iii;
160 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 160 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
161 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 161 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
162 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 162 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
163 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 163 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
164 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 164 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
165 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 165 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
166 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 166 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
167 167
168 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 168 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
169 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 169 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
170 ++iii; 170 ++iii;
171 171
172 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 172 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
173 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 173 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
174 ++iii; 174 ++iii;
175 175
176 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); 176 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame );
177 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 177 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
178 ++iii; 178 ++iii;
179 179
180 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); 180 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame );
181 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 181 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
182 ++iii; 182 ++iii;
183 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); 183 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0);
184 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); 184 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame);
185 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 185 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
186 ++iii; 186 ++iii;
187 187
188 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 188 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
189 gr = proGr; 189 gr = proGr;
190 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 190 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
191 ++iii; 191 ++iii;
192 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 192 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
193 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); 193 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
194 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 194 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
195 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 195 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
196 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 196 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
197 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 197 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
198 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 198 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
199 199
200 200
201 phoneWidget = new QVBox( topFrame); 201 phoneWidget = new QVBox( topFrame);
202 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 202 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
203 ++iii; 203 ++iii;
204 mWriteContactToSIM= new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 204 mWriteContactToSIM= new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
205 QHBox* temphb = new QHBox( phoneWidget ); 205 QHBox* temphb = new QHBox( phoneWidget );
206 new QLabel( i18n("I/O device: "), temphb ); 206 new QLabel( i18n("I/O device: "), temphb );
207 mPhoneDevice = new QLineEdit( temphb); 207 mPhoneDevice = new QLineEdit( temphb);
208 button = new QPushButton( i18n("Help..."), temphb ); 208 button = new QPushButton( i18n("Help..."), temphb );
209 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 209 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
210 210
211 211
212 temphb = new QHBox( phoneWidget ); 212 temphb = new QHBox( phoneWidget );
213 new QLabel( i18n("Connection: "), temphb ); 213 new QLabel( i18n("Connection: "), temphb );
214 mPhoneConnection = new QLineEdit( temphb); 214 mPhoneConnection = new QLineEdit( temphb);
215 button = new QPushButton( i18n("Help..."), temphb ); 215 button = new QPushButton( i18n("Help..."), temphb );
216 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 216 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
217 217
218 218
219 temphb = new QHBox( phoneWidget ); 219 temphb = new QHBox( phoneWidget );
220 new QLabel( i18n("Model(opt.): "), temphb ); 220 new QLabel( i18n("Model(opt.): "), temphb );
221 mPhoneModel = new QLineEdit( temphb); 221 mPhoneModel = new QLineEdit( temphb);
222 button = new QPushButton( i18n("Help..."), temphb ); 222 button = new QPushButton( i18n("Help..."), temphb );
223 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 223 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
224 224
225 // *** local 225 // *** local
226 localFileWidget = new QVBox( topFrame); 226 localFileWidget = new QVBox( topFrame);
227 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 227 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
228 ++iii; 228 ++iii;
229 temphb = new QHBox( localFileWidget ); 229 temphb = new QHBox( localFileWidget );
230 230
231 lab = new QLabel( i18n("Local file Cal:"), temphb ); 231 lab = new QLabel( i18n("Local file Cal:"), temphb );
232 lab = new QLabel( i18n("Local file ABook:"), temphb ); 232 lab = new QLabel( i18n("Local file ABook:"), temphb );
233 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 233 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
234 temphb = new QHBox( localFileWidget ); 234 temphb = new QHBox( localFileWidget );
235 button = new QPushButton( i18n("Choose..."), temphb ); 235 button = new QPushButton( i18n("Choose..."), temphb );
236 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 236 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
237 button = new QPushButton( i18n("Choose..."), temphb ); 237 button = new QPushButton( i18n("Choose..."), temphb );
238 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 238 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
239 button = new QPushButton( i18n("Choose..."), temphb ); 239 button = new QPushButton( i18n("Choose..."), temphb );
240 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 240 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
241 temphb = new QHBox( localFileWidget ); 241 temphb = new QHBox( localFileWidget );
242 242
243 mRemoteFile = new QLineEdit( temphb); 243 mRemoteFile = new QLineEdit( temphb);
244 mRemoteFileAB = new QLineEdit( temphb); 244 mRemoteFileAB = new QLineEdit( temphb);
245 mRemoteFilePWM = new QLineEdit( temphb); 245 mRemoteFilePWM = new QLineEdit( temphb);
246 246
247 // *** remote 247 // *** remote
248 remoteFileWidget = new QVBox( topFrame); 248 remoteFileWidget = new QVBox( topFrame);
249 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 249 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
250 ++iii; 250 ++iii;
251 temphb = new QHBox( remoteFileWidget ); 251 temphb = new QHBox( remoteFileWidget );
252 new QLabel( i18n("Calendar:"), temphb); 252 new QLabel( i18n("Calendar:"), temphb);
253 new QLabel( i18n("AddressBook:"), temphb); 253 new QLabel( i18n("AddressBook:"), temphb);
254 new QLabel( i18n("PWManager:"), temphb); 254 new QLabel( i18n("PWManager:"), temphb);
255 255
256 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 256 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
257 temphb = new QHBox( remoteFileWidget ); 257 temphb = new QHBox( remoteFileWidget );
258 mRemotePrecommand = new QLineEdit(temphb); 258 mRemotePrecommand = new QLineEdit(temphb);
259 mRemotePrecommandAB = new QLineEdit(temphb); 259 mRemotePrecommandAB = new QLineEdit(temphb);
260 mRemotePrecommandPWM = new QLineEdit(temphb); 260 mRemotePrecommandPWM = new QLineEdit(temphb);
261 261
262 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 262 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
263 temphb = new QHBox( remoteFileWidget ); 263 temphb = new QHBox( remoteFileWidget );
264 mLocalTempFile = new QLineEdit(temphb); 264 mLocalTempFile = new QLineEdit(temphb);
265 mLocalTempFileAB = new QLineEdit(temphb); 265 mLocalTempFileAB = new QLineEdit(temphb);
266 mLocalTempFilePWM = new QLineEdit(temphb); 266 mLocalTempFilePWM = new QLineEdit(temphb);
267 267
268 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 268 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
269 temphb = new QHBox( remoteFileWidget ); 269 temphb = new QHBox( remoteFileWidget );
270 mRemotePostcommand = new QLineEdit(temphb ); 270 mRemotePostcommand = new QLineEdit(temphb );
271 mRemotePostcommandAB = new QLineEdit(temphb ); 271 mRemotePostcommandAB = new QLineEdit(temphb );
272 mRemotePostcommandPWM = new QLineEdit(temphb ); 272 mRemotePostcommandPWM = new QLineEdit(temphb );
273 273
274 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 274 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
275 temphb = new QHBox( remoteFileWidget ); 275 temphb = new QHBox( remoteFileWidget );
276 button = new QPushButton( i18n("ssh/scp"), temphb ); 276 button = new QPushButton( i18n("ssh/scp"), temphb );
277 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 277 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
278 button = new QPushButton( i18n("ftp"), temphb ); 278 button = new QPushButton( i18n("ftp"), temphb );
279 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 279 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
280 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 280 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
281 281
282 // *** pi-sync 282 // *** pi-sync
283 piWidget = new QVBox( topFrame); 283 piWidget = new QVBox( topFrame);
284 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 284 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
285 ++iii; 285 ++iii;
286 temphb = new QHBox( piWidget ); 286 temphb = new QHBox( piWidget );
287 new QLabel( i18n("Calendar:"), temphb); 287 new QLabel( i18n("Calendar:"), temphb);
288 new QLabel( i18n("AddressBook:"), temphb); 288 new QLabel( i18n("AddressBook:"), temphb);
289 new QLabel( i18n("PWManager:"), temphb); 289 new QLabel( i18n("PWManager:"), temphb);
290 290
291 lab = new QLabel( i18n("Password for remote access:"), piWidget); 291 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
292 temphb = new QHBox( piWidget ); 292 temphb = new QHBox( piWidget );
293 mRemotePw = new QLineEdit(temphb); 293 mRemotePw = new QLineEdit(temphb);
294 mRemotePwAB = new QLineEdit(temphb); 294 mRemotePwAB = new QLineEdit(temphb);
295 mRemotePwPWM = new QLineEdit(temphb); 295 mRemotePwPWM = new QLineEdit(temphb);
296 296
297 lab = new QLabel( i18n("Remote IP address:"), piWidget); 297 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
298 temphb = new QHBox( piWidget ); 298 temphb = new QHBox( piWidget );
299 mRemoteIP = new QLineEdit(temphb); 299 mRemoteIP = new QLineEdit(temphb);
300 mRemoteIPAB = new QLineEdit(temphb); 300 mRemoteIPAB = new QLineEdit(temphb);
301 mRemoteIPPWM = new QLineEdit(temphb); 301 mRemoteIPPWM = new QLineEdit(temphb);
302 302
303 lab = new QLabel( i18n("Remote port number:"), piWidget); 303 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
304 temphb = new QHBox( piWidget ); 304 temphb = new QHBox( piWidget );
305 mRemotePort = new QLineEdit(temphb); 305 mRemotePort = new QLineEdit(temphb);
306 mRemotePortAB = new QLineEdit(temphb); 306 mRemotePortAB = new QLineEdit(temphb);
307 mRemotePortPWM = new QLineEdit(temphb); 307 mRemotePortPWM = new QLineEdit(temphb);
308 308
309} 309}
310 310
311 311
312 312
313 313
314 314
315void KSyncPrefsDialog::slotOK() 315void KSyncPrefsDialog::slotOK()
316{ 316{
317 if ( mMyMachineName->text() == "undefined" ) { 317 if ( mMyMachineName->text() == "undefined" ) {
318 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 318 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
319 return; 319 return;
320 } 320 }
321 int i; 321 int i;
322 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 322 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
323 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 323 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
324 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 324 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
325 return; 325 return;
326 } 326 }
327 } 327 }
328 usrWriteConfig(); 328 usrWriteConfig();
329 QDialog::accept(); 329 QDialog::accept();
330} 330}
331void KSyncPrefsDialog::accept() 331void KSyncPrefsDialog::accept()
332{ 332{
333 slotOK(); 333 slotOK();
334} 334}
335void KSyncPrefsDialog::chooseFile() 335void KSyncPrefsDialog::chooseFile()
336{ 336{
337 QString fn = QDir::homeDirPath(); 337 QString fn = QDir::homeDirPath();
338 338
339 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 339 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
340 if ( fn == "" ) 340 if ( fn == "" )
341 return; 341 return;
342 mRemoteFile->setText( fn ); 342 mRemoteFile->setText( fn );
343} 343}
344 344
345void KSyncPrefsDialog::chooseFileAB() 345void KSyncPrefsDialog::chooseFileAB()
346{ 346{
347 QString fn = QDir::homeDirPath(); 347 QString fn = QDir::homeDirPath();
348 348
349 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 349 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
350 if ( fn == "" ) 350 if ( fn == "" )
351 return; 351 return;
352 mRemoteFileAB->setText( fn ); 352 mRemoteFileAB->setText( fn );
353} 353}
354 354
355void KSyncPrefsDialog::chooseFilePWM() 355void KSyncPrefsDialog::chooseFilePWM()
356{ 356{
357 QString fn = QDir::homeDirPath(); 357 QString fn = QDir::homeDirPath();
358 358
359 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 359 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
360 if ( fn == "" ) 360 if ( fn == "" )
361 return; 361 return;
362 mRemoteFilePWM->setText( fn ); 362 mRemoteFilePWM->setText( fn );
363} 363}
364 364
365void KSyncPrefsDialog::textChanged( const QString & s ) 365void KSyncPrefsDialog::textChanged( const QString & s )
366{ 366{
367 if ( mProfileBox->count() == 0 ) 367 if ( mProfileBox->count() == 0 )
368 return; 368 return;
369 if ( currentSelection < 3 ) { 369 if ( currentSelection < 3 ) {
370 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 370 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
371 mProfileBox->blockSignals( true ); 371 mProfileBox->blockSignals( true );
372 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 372 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
373 mProfileBox->blockSignals( false ); 373 mProfileBox->blockSignals( false );
374 return; 374 return;
375 } 375 }
376 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 376 //qDebug("cur i %d ",mProfileBox-> currentItem () );
377 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 377 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
378 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 378 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
379 prof->setName( s ); 379 prof->setName( s );
380 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 380 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
381} 381}
382void KSyncPrefsDialog::profileChanged( int item ) 382void KSyncPrefsDialog::profileChanged( int item )
383{ 383{
384 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 384 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
385 KSyncProfile* prof; 385 KSyncProfile* prof;
386 saveProfile(); 386 saveProfile();
387 currentSelection = item; 387 currentSelection = item;
388 prof = mSyncProfiles.at(item) ; 388 prof = mSyncProfiles.at(item) ;
389 389
390 mRemotePw->setText(prof->getRemotePw()); 390 mRemotePw->setText(prof->getRemotePw());
391 mRemoteIP->setText(prof->getRemoteIP()); 391 mRemoteIP->setText(prof->getRemoteIP());
392 mRemotePort->setText(prof->getRemotePort()); 392 mRemotePort->setText(prof->getRemotePort());
393 393
394 mRemotePwAB->setText(prof->getRemotePwAB()); 394 mRemotePwAB->setText(prof->getRemotePwAB());
395 mRemoteIPAB->setText(prof->getRemoteIPAB()); 395 mRemoteIPAB->setText(prof->getRemoteIPAB());
396 mRemotePortAB->setText(prof->getRemotePortAB()); 396 mRemotePortAB->setText(prof->getRemotePortAB());
397 397
398 mRemotePwPWM->setText(prof->getRemotePwPWM()); 398 mRemotePwPWM->setText(prof->getRemotePwPWM());
399 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 399 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
400 mRemotePortPWM->setText(prof->getRemotePortPWM()); 400 mRemotePortPWM->setText(prof->getRemotePortPWM());
401 401
402 mRemotePrecommand->setText(prof->getPreSyncCommand()); 402 mRemotePrecommand->setText(prof->getPreSyncCommand());
403 mRemotePostcommand->setText(prof->getPostSyncCommand()); 403 mRemotePostcommand->setText(prof->getPostSyncCommand());
404 mLocalTempFile->setText(prof->getLocalTempFile()); 404 mLocalTempFile->setText(prof->getLocalTempFile());
405 mRemoteFile->setText(prof->getRemoteFileName()) ; 405 mRemoteFile->setText(prof->getRemoteFileName()) ;
406 406
407 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 407 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
408 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 408 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
409 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 409 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
410 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 410 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
411 411
412 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 412 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
413 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 413 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
414 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 414 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
415 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 415 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
416 416
417 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 417 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
418 mPhoneDevice->setText(prof->getPhoneDevice()); 418 mPhoneDevice->setText(prof->getPhoneDevice());
419 mPhoneConnection->setText(prof->getPhoneConnection()); 419 mPhoneConnection->setText(prof->getPhoneConnection());
420 mPhoneModel->setText(prof->getPhoneModel()); 420 mPhoneModel->setText(prof->getPhoneModel());
421 421
422 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 422 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
423 mAskForPreferences->setChecked( prof->getAskForPreferences()); 423 mAskForPreferences->setChecked( prof->getAskForPreferences());
424 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 424 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
425 mWriteBackFile->setChecked( prof->getWriteBackFile()); 425 mWriteBackFile->setChecked( prof->getWriteBackFile());
426 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 426 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
427 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 427 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
428 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 428 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
429 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 429 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
430 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 430 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
431 431
432 switch ( prof->getSyncPrefs() ) { 432 switch ( prof->getSyncPrefs() ) {
433 case 0: 433 case 0:
434 loc->setChecked( true); 434 loc->setChecked( true);
435 break; 435 break;
436 case 1: 436 case 1:
437 rem->setChecked( true ); 437 rem->setChecked( true );
438 break; 438 break;
439 case 2: 439 case 2:
440 newest->setChecked( true); 440 newest->setChecked( true);
441 break; 441 break;
442 case 3: 442 case 3:
443 ask->setChecked( true); 443 ask->setChecked( true);
444 break; 444 break;
445 case 4: 445 case 4:
446 f_loc->setChecked( true); 446 f_loc->setChecked( true);
447 break; 447 break;
448 case 5: 448 case 5:
449 f_rem->setChecked( true); 449 f_rem->setChecked( true);
450 break; 450 break;
451 case 6: 451 case 6:
452 //both->setChecked( true); 452 //both->setChecked( true);
453 break; 453 break;
454 default: 454 default:
455 break; 455 break;
456 } 456 }
457 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 457 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
458 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 458 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
459 mIsPi->setChecked(prof->getIsPiSync()) ; 459 mIsPi->setChecked(prof->getIsPiSync()) ;
460 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); 460 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
461 proGr->setEnabled( item > 2 ); 461 proGr->setEnabled( item > 2 );
462 if ( item < 3 ) { 462 if ( item < 3 ) {
463 localFileWidget->hide(); 463 localFileWidget->hide();
464 remoteFileWidget->hide(); 464 remoteFileWidget->hide();
465 phoneWidget->hide(); 465 phoneWidget->hide();
466 piWidget->hide(); 466 piWidget->hide();
467 467
468 } else 468 } else
469 kindChanged( prof->getIsLocalFileSync() ); 469 kindChanged( prof->getIsLocalFileSync() );
470} 470}
471 471
472void KSyncPrefsDialog::fillSSH() 472void KSyncPrefsDialog::fillSSH()
473{ 473{
474 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 474 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
475 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 475 mLocalTempFile->setText("/tmp/mycalendar.ics" );
476 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 476 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
477 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 477 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
478 mLocalTempFileAB->setText("/tmp/std.vcf" ); 478 mLocalTempFileAB->setText("/tmp/std.vcf" );
479 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 479 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
480 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 480 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
481 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 481 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
482 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 482 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
483} 483}
484void KSyncPrefsDialog::fillFTP() 484void KSyncPrefsDialog::fillFTP()
485{ 485{
486 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 486 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
487 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 487 mLocalTempFile->setText("/tmp/mycalendar.ics" );
488 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 488 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
489 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 489 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
490 mLocalTempFileAB->setText("/tmp/std.vcf" ); 490 mLocalTempFileAB->setText("/tmp/std.vcf" );
491 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 491 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
492 492
493 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 493 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
494 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 494 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
495 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 495 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
496 496
497} 497}
498void KSyncPrefsDialog::kindChanged( bool b ) 498void KSyncPrefsDialog::kindChanged( bool b )
499{ 499{
500 500
501 if ( mIsLocal->isChecked () ) 501 if ( mIsLocal->isChecked () )
502 localFileWidget->show(); 502 localFileWidget->show();
503 else 503 else
504 localFileWidget->hide(); 504 localFileWidget->hide();
505 505
506 if ( mIsNotLocal->isChecked () ) 506 if ( mIsNotLocal->isChecked () )
507 remoteFileWidget->show(); 507 remoteFileWidget->show();
508 else 508 else
509 remoteFileWidget->hide(); 509 remoteFileWidget->hide();
510 510
511 if ( mIsPhone->isChecked () ) { 511 if ( mIsPhone->isChecked () ) {
512 phoneWidget->show(); 512 phoneWidget->show();
513 } 513 }
514 else { 514 else {
515 phoneWidget->hide(); 515 phoneWidget->hide();
516 } 516 }
517 if ( mIsPi->isChecked () ) { 517 if ( mIsPi->isChecked () ) {
518 piWidget->show(); 518 piWidget->show();
519 } 519 }
520 else { 520 else {
521 piWidget->hide(); 521 piWidget->hide();
522 } 522 }
523 523
524} 524}
525void KSyncPrefsDialog::deleteProfile() 525void KSyncPrefsDialog::deleteProfile()
526{ 526{
527 //qDebug("KSyncPrefsDialog::deleteProfile() "); 527 //qDebug("KSyncPrefsDialog::deleteProfile() ");
528 if ( currentSelection >= 0 ) { 528 if ( currentSelection >= 0 ) {
529 if ( currentSelection < 3 ) { 529 if ( currentSelection < 3 ) {
530 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 530 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
531 return; 531 return;
532 } 532 }
533 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 533 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
534 mSyncProfiles.remove( temp ); 534 mSyncProfiles.remove( temp );
535 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 535 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
536 insertProfiles(); 536 insertProfiles();
537 } 537 }
538} 538}
539 539
540void KSyncPrefsDialog::saveProfile() 540void KSyncPrefsDialog::saveProfile()
541{ 541{
542 KSyncProfile* prof; 542 KSyncProfile* prof;
543 if ( currentSelection >= 0 ) { 543 if ( currentSelection >= 0 ) {
544 prof = mSyncProfiles.at(currentSelection) ; 544 prof = mSyncProfiles.at(currentSelection) ;
545 545
546 prof->setRemotePw( mRemotePw->text()); 546 prof->setRemotePw( mRemotePw->text());
547 prof->setRemoteIP( mRemoteIP->text()); 547 prof->setRemoteIP( mRemoteIP->text());
548 prof->setRemotePort( mRemotePort->text()); 548 prof->setRemotePort( mRemotePort->text());
549 549
550 prof->setRemotePwAB( mRemotePwAB->text()); 550 prof->setRemotePwAB( mRemotePwAB->text());
551 prof->setRemoteIPAB( mRemoteIPAB->text()); 551 prof->setRemoteIPAB( mRemoteIPAB->text());
552 prof->setRemotePortAB( mRemotePortAB->text()); 552 prof->setRemotePortAB( mRemotePortAB->text());
553 553
554 prof->setRemotePwPWM( mRemotePwPWM->text()); 554 prof->setRemotePwPWM( mRemotePwPWM->text());
555 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 555 prof->setRemoteIPPWM( mRemoteIPPWM->text());
556 prof->setRemotePortPWM( mRemotePortPWM->text()); 556 prof->setRemotePortPWM( mRemotePortPWM->text());
557 557
558 prof->setPreSyncCommand( mRemotePrecommand->text()); 558 prof->setPreSyncCommand( mRemotePrecommand->text());
559 prof->setPostSyncCommand( mRemotePostcommand->text() ); 559 prof->setPostSyncCommand( mRemotePostcommand->text() );
560 prof->setLocalTempFile( mLocalTempFile->text()); 560 prof->setLocalTempFile( mLocalTempFile->text());
561 prof->setRemoteFileName( mRemoteFile->text() ); 561 prof->setRemoteFileName( mRemoteFile->text() );
562 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 562 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
563 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 563 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
564 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 564 prof->setLocalTempFileAB( mLocalTempFileAB->text());
565 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 565 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
566 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 566 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
567 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 567 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
568 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 568 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
569 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 569 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
570 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 570 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
571 prof->setAskForPreferences( mAskForPreferences->isChecked()); 571 prof->setAskForPreferences( mAskForPreferences->isChecked());
572 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 572 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
573 prof->setWriteBackFile( mWriteBackFile->isChecked()); 573 prof->setWriteBackFile( mWriteBackFile->isChecked());
574 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 574 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
575 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 575 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
576 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 576 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
577 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 577 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
578 prof->setSyncPrefs( syncprefs); 578 prof->setSyncPrefs( syncprefs);
579 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 579 prof->setIsLocalFileSync( mIsLocal->isChecked() );
580 prof->setIsPhoneSync( mIsPhone->isChecked() ); 580 prof->setIsPhoneSync( mIsPhone->isChecked() );
581 prof->setIsPiSync( mIsPi->isChecked() ); 581 prof->setIsPiSync( mIsPi->isChecked() );
582 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 582 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
583 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 583 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
584 584
585 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 585 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
586 prof->setPhoneDevice( mPhoneDevice->text() ); 586 prof->setPhoneDevice( mPhoneDevice->text() );
587 prof->setPhoneConnection( mPhoneConnection->text() ); 587 prof->setPhoneConnection( mPhoneConnection->text() );
588 prof->setPhoneModel( mPhoneModel->text() ); 588 prof->setPhoneModel( mPhoneModel->text() );
589 589
590 } 590 }
591 591
592} 592}
593 593
594void KSyncPrefsDialog::insertProfiles() 594void KSyncPrefsDialog::insertProfiles()
595{ 595{
596 int curItem = mProfileBox->currentItem(); 596 int curItem = mProfileBox->currentItem();
597 mProfileBox->blockSignals( true ); 597 mProfileBox->blockSignals( true );
598 mProfileBox->clear(); 598 mProfileBox->clear();
599 mProfileBox->insertStringList (mSyncProfileNames ); 599 mProfileBox->insertStringList (mSyncProfileNames );
600 int item = mSyncProfileNames.count() -1; 600 int item = mSyncProfileNames.count() -1;
601 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 601 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
602 mProfileBox->setCurrentItem( curItem ); 602 mProfileBox->setCurrentItem( curItem );
603 else if ( item >= 0 ) { 603 else if ( item >= 0 ) {
604 mProfileBox->setCurrentItem( item ); 604 mProfileBox->setCurrentItem( item );
605 } 605 }
606 currentSelection = -1; 606 currentSelection = -1;
607 if ( mSyncProfileNames.count() > 0 ) { 607 if ( mSyncProfileNames.count() > 0 ) {
608 //qDebug(" profileChanged( mProfileBox->currentItem() "); 608 //qDebug(" profileChanged( mProfileBox->currentItem() ");
609 profileChanged( mProfileBox->currentItem() ); 609 profileChanged( mProfileBox->currentItem() );
610 currentSelection = mProfileBox->currentItem(); 610 currentSelection = mProfileBox->currentItem();
611 } 611 }
612 mProfileBox->blockSignals( false ); 612 mProfileBox->blockSignals( false );
613} 613}
614 614
615void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 615void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
616{ 616{
617 saveProfile(); 617 saveProfile();
618 mSyncProfiles.append( temp ); 618 mSyncProfiles.append( temp );
619 mSyncProfileNames << temp->getName(); 619 mSyncProfileNames << temp->getName();
620 insertProfiles(); 620 insertProfiles();
621 int last = mProfileBox->count() -1; 621 int last = mProfileBox->count() -1;
622 mProfileBox->blockSignals( true ); 622 mProfileBox->blockSignals( true );
623 mProfileBox->setCurrentItem( last ); 623 mProfileBox->setCurrentItem( last );
624 mProfileBox->blockSignals( false ); 624 mProfileBox->blockSignals( false );
625 profileChanged(last); 625 profileChanged(last);
626} 626}
627void KSyncPrefsDialog::newProfile() 627void KSyncPrefsDialog::newProfile()
628{ 628{
629 addProfile ( new KSyncProfile () ); 629 addProfile ( new KSyncProfile () );
630} 630}
631 631
632void KSyncPrefsDialog::cloneProfile() 632void KSyncPrefsDialog::cloneProfile()
633{ 633{
634 if ( currentSelection >= 0 ) 634 if ( currentSelection >= 0 )
635 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 635 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
636 else 636 else
637 newProfile(); 637 newProfile();
638} 638}
639 639
640void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 640void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
641{ 641{
642 mMyMachineName->setText( name ); 642 mMyMachineName->setText( name );
643 643
644} 644}
645QString KSyncPrefsDialog::getLocalMachineName ( ) 645QString KSyncPrefsDialog::getLocalMachineName ( )
646{ 646{
647 return mMyMachineName->text(); 647 return mMyMachineName->text();
648} 648}
649 649
650QStringList KSyncPrefsDialog::getSyncProfileNames() 650QStringList KSyncPrefsDialog::getSyncProfileNames()
651{ 651{
652 return mSyncProfileNames; 652 return mSyncProfileNames;
653} 653}
654void KSyncPrefsDialog::usrReadConfig() 654void KSyncPrefsDialog::usrReadConfig()
655{ 655{
656 //KConfig *config = KOGlobals::config(); 656 //KConfig *config = KOGlobals::config();
657 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 657 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
658 config.setGroup("General"); 658 config.setGroup("General");
659 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 659 mSyncProfileNames =config.readListEntry("SyncProfileNames");
660 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 660 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
661 int i; 661 int i;
662 KSyncProfile* temp ; 662 KSyncProfile* temp ;
663 mSyncProfiles.clear(); 663 mSyncProfiles.clear();
664 for ( i = 0; i < mSyncProfileNames.count();++i ) { 664 for ( i = 0; i < mSyncProfileNames.count();++i ) {
665 temp = new KSyncProfile (); 665 temp = new KSyncProfile ();
666 temp->setName( mSyncProfileNames[i] ); 666 temp->setName( mSyncProfileNames[i] );
667 temp->readConfig( &config ); 667 temp->readConfig( &config );
668 mSyncProfiles.append( temp ); 668 mSyncProfiles.append( temp );
669 } 669 }
670 insertProfiles(); 670 insertProfiles();
671 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 671 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
672} 672}
673 673
674 674
675void KSyncPrefsDialog::usrWriteConfig() 675void KSyncPrefsDialog::usrWriteConfig()
676{ 676{
677 saveProfile(); 677 saveProfile();
678 if ( currentSelection >= 0 ) 678 if ( currentSelection >= 0 )
679 profileChanged(currentSelection); 679 profileChanged(currentSelection);
680 //KConfig *config = KOGlobals::config(); 680 //KConfig *config = KOGlobals::config();
681 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 681 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
682 KSyncProfile* prof = mSyncProfiles.first(); 682 KSyncProfile* prof = mSyncProfiles.first();
683 QStringList externalSyncProfileNames; 683 QStringList externalSyncProfileNames;
684 externalSyncProfileNames.append("Sharp_DTM");; 684 externalSyncProfileNames.append("Sharp_DTM");;
685 while ( prof ) { 685 while ( prof ) {
686 prof->writeConfig(&config); 686 prof->writeConfig(&config);
687 if ( prof->getIsPhoneSync( ) ) 687 if ( prof->getIsPhoneSync( ) )
688 externalSyncProfileNames.append(prof->getName( ) ); 688 externalSyncProfileNames.append(prof->getName( ) );
689 prof = mSyncProfiles.next(); 689 prof = mSyncProfiles.next();
690 } 690 }
691 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 691 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
692 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 692 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
693 config.setGroup("General"); 693 config.setGroup("General");
694 config.writeEntry("SyncProfileNames",mSyncProfileNames); 694 config.writeEntry("SyncProfileNames",mSyncProfileNames);
695 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 695 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
696 config.writeEntry("LocalMachineName",mMyMachineName->text()); 696 config.writeEntry("LocalMachineName",mMyMachineName->text());
697 config.sync(); 697 config.sync();
698} 698}
699 699
700void KSyncPrefsDialog::helpDevice() 700void KSyncPrefsDialog::helpDevice()
701{ 701{
702 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 702 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
703#ifdef _WIN32_ 703#ifdef _WIN32_
704 hint += "Leave empty for Irda.\n" 704 hint += "Leave empty for Irda.\n"
705 "com1:\n(first serial port)\n" 705 "com1:\n(first serial port)\n"
706 "usb not supported\n" 706 "usb not supported\n"
707 "???\n(bluetooth device address)\n"; 707 "???\n(bluetooth device address)\n";
708 708
709#else 709#else
710 hint += "/dev/ircomm\n(Irda)\n" 710 hint += "/dev/ircomm\n(Irda)\n"
711 "/dev/ttyS0\n(first serial port)\n" 711 "/dev/ttyS0\n(first serial port)\n"
712 "/dev/ttyUSB0\n(first device usb port)\n" 712 "/dev/ttyUSB0\n(first device usb port)\n"
713 "???\n(bluetooth device address)\n"; 713 "???\n(bluetooth device address)\n";
714#endif 714#endif
715 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 715 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
716} 716}
717void KSyncPrefsDialog::helpModel() 717void KSyncPrefsDialog::helpModel()
718{ 718{
719 QString hint = i18n("Leave empty or\ninsert name of phone model:\n"); 719 QString hint = i18n("Leave empty or\ninsert name of phone model:\n");
720 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 720 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
721 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 721 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
722 722
723} 723}
724void KSyncPrefsDialog::helpConnection() 724void KSyncPrefsDialog::helpConnection()
725{ 725{
726 QString hint = i18n("Insert kind of connection,e.g.:\n"); 726 QString hint = i18n("Insert kind of connection,e.g.:\n");
727 hint += "irda | Nokia FBUS over infrared\n" 727 hint += "irda | Nokia FBUS over infrared\n"
728 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 728 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
729 "irdaobex | set also model as obex\n" 729 "irdaobex | set also model as obex\n"
730 "fbus | Nokia FBUS2 serial\n"; 730 "fbus | Nokia FBUS2 serial\n";
731 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 731 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
732} 732}