summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-04 18:41:26 (UTC)
committer zautrix <zautrix>2004-10-04 18:41:26 (UTC)
commit144952942e57780587739a46253cc7305c79f27c (patch) (unidiff)
tree82ad5b9b98c6243a9d2c8902f4851c421e70508c /korganizer
parent2a99a7ca0816fd68b7fcf2f1fee023aef019000d (diff)
downloadkdepimpi-144952942e57780587739a46253cc7305c79f27c.zip
kdepimpi-144952942e57780587739a46253cc7305c79f27c.tar.gz
kdepimpi-144952942e57780587739a46253cc7305c79f27c.tar.bz2
more sync fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp133
-rw-r--r--korganizer/mainwindow.h17
2 files changed, 140 insertions, 10 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index e4b7869..da73caf 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1908,110 +1908,124 @@ void MainWindow::enableQuick()
1908 lay.addWidget( &lepw); 1908 lay.addWidget( &lepw);
1909 dia.setFixedSize( 230,80 ); 1909 dia.setFixedSize( 230,80 );
1910 dia.setCaption( i18n("Enter port for Pi-Sync") ); 1910 dia.setCaption( i18n("Enter port for Pi-Sync") );
1911 QPushButton pb ( "OK", &dia); 1911 QPushButton pb ( "OK", &dia);
1912 lay.addWidget( &pb ); 1912 lay.addWidget( &pb );
1913 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1913 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1914 dia.show(); 1914 dia.show();
1915 int res = dia.exec(); 1915 int res = dia.exec();
1916 if ( res ) 1916 if ( res )
1917 retfile = lab.text(); 1917 retfile = lab.text();
1918 else 1918 else
1919 return; 1919 return;
1920 dia.hide(); 1920 dia.hide();
1921 passWordPiSync = lepw.text(); 1921 passWordPiSync = lepw.text();
1922 qApp->processEvents(); 1922 qApp->processEvents();
1923 KOPrefs::instance()->mPassiveSyncPort = retfile; 1923 KOPrefs::instance()->mPassiveSyncPort = retfile;
1924 bool ok; 1924 bool ok;
1925 Q_UINT16 port = retfile.toUInt(&ok); 1925 Q_UINT16 port = retfile.toUInt(&ok);
1926 if ( ! ok ) { 1926 if ( ! ok ) {
1927 KMessageBox::information( this, i18n("No valid port")); 1927 KMessageBox::information( this, i18n("No valid port"));
1928 return; 1928 return;
1929 } 1929 }
1930 qDebug("port %d ", port); 1930 qDebug("port %d ", port);
1931 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); 1931 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
1932 mServerSocket->setFileName( defaultFileName() );
1932 qDebug("connected "); 1933 qDebug("connected ");
1933 if ( !mServerSocket->ok() ) { 1934 if ( !mServerSocket->ok() ) {
1934 qWarning("Failed to bind to port %d", port); 1935 qWarning("Failed to bind to port %d", port);
1935 delete mServerSocket; 1936 delete mServerSocket;
1936 mServerSocket = 0; 1937 mServerSocket = 0;
1937 return; 1938 return;
1938 } 1939 }
1939 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); 1940 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
1940 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); 1941 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
1942 // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1943 //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1941} 1944}
1942void MainWindow::sendFile(QSocket* socket) 1945void MainWindow::sendFile(QSocket* socket)
1943{ 1946{
1944 setCaption( i18n("Received request for file") ); 1947 setCaption( i18n("Received request for file") );
1945 qDebug("MainWindow::sendFile(QSocket* s) "); 1948 qDebug("MainWindow::sendFile(QSocket* s) ");
1946 if ( mSyncActionDialog ) 1949 if ( mSyncActionDialog )
1947 delete mSyncActionDialog; 1950 delete mSyncActionDialog;
1948 mSyncActionDialog = new QDialog ( this, "input-dialog", true ); 1951 mSyncActionDialog = new QDialog ( this, "input-dialog", true );
1949 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); 1952 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
1950 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); 1953 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
1951 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1954 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1952 lay->addWidget( label); 1955 lay->addWidget( label);
1953 lay->setMargin(7); 1956 lay->setMargin(7);
1954 lay->setSpacing(7); 1957 lay->setSpacing(7);
1955 mSyncActionDialog->setFixedSize( 200,100 ); 1958 mSyncActionDialog->setFixedSize( 200,100 );
1956 mSyncActionDialog->show(); 1959 mSyncActionDialog->show();
1957 qDebug("saving ... "); 1960 qDebug("saving ... ");
1958 save(); 1961 save();
1959 qApp->processEvents(); 1962 qApp->processEvents();
1960 QString fileName = defaultFileName(); 1963 QString fileName = defaultFileName();
1961 QFile file( fileName ); 1964 QFile file( fileName );
1962 if (!file.open( IO_ReadOnly ) ) { 1965 if (!file.open( IO_ReadOnly ) ) {
1963 setCaption( i18n("Error open file") ); 1966 setCaption( i18n("Error open file") );
1964 delete mSyncActionDialog; 1967 delete mSyncActionDialog;
1965 mSyncActionDialog = 0; 1968 mSyncActionDialog = 0;
1966 qDebug("error open cal file "); 1969 qDebug("error open cal file ");
1967 return ; 1970 return ;
1968 1971
1969 } 1972 }
1970 setCaption( i18n("Sending file...") ); 1973 setCaption( i18n("Sending file...") );
1971 QTextStream ts( &file ); 1974 QTextStream ts( &file );
1972 ts.setCodec( QTextCodec::codecForName("utf8") ); 1975 ts.setCodec( QTextCodec::codecForName("utf8") );
1973 QTextStream os( socket ); 1976 QTextStream os( socket );
1974 os.setCodec( QTextCodec::codecForName("utf8") ); 1977 os.setCodec( QTextCodec::codecForName("utf8") );
1975 //os.setEncoding( QTextStream::UnicodeUTF8 ); 1978 //os.setEncoding( QTextStream::UnicodeUTF8 );
1976 while ( ! ts.atEnd() ) { 1979 while ( ! ts.atEnd() ) {
1977 os << ts.readLine() << "\n"; 1980 os << ts.readLine() << "\n";
1978 } 1981 }
1979 //os << ts.read(); 1982 //os << ts.read();
1980 socket->close(); 1983 socket->close();
1981 file.close(); 1984 file.close();
1982 setCaption( i18n("File sent. Waiting to get back synced file") ); 1985 setCaption( i18n("File sent. Waiting to get back synced file") );
1983 qDebug("file sent "); 1986 qDebug("file sent ");
1984} 1987}
1985void MainWindow::getFile(QSocket* socket) 1988void MainWindow::getFile( bool success )
1986{ 1989{
1990 if ( ! success ) {
1991 setCaption( i18n("Error receiving file. Nothing changed!") );
1992 return;
1993 }
1994 // pending adjust time for watchSavedFile()
1995 //mView->watchSavedFile();
1996 mView->openCalendar( defaultFileName() );
1997 setCaption( i18n("Pi-Sync successful!") );
1998
1999
2000#if 0
1987 setCaption( i18n("Receiving synced file...") ); 2001 setCaption( i18n("Receiving synced file...") );
1988 2002
1989 piTime.start(); 2003 piTime.start();
1990 piSocket = socket; 2004 piSocket = socket;
1991 piFileString = ""; 2005 piFileString = "";
1992 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 2006 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1993 2007#endif
1994 2008
1995} 2009}
1996void MainWindow::readBackFileFromSocket() 2010void MainWindow::readBackFileFromSocket()
1997{ 2011{
1998 qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 2012 qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1999 while ( piSocket->canReadLine () ) { 2013 while ( piSocket->canReadLine () ) {
2000 piTime.restart(); 2014 piTime.restart();
2001 QString line = piSocket->readLine (); 2015 QString line = piSocket->readLine ();
2002 piFileString += line; 2016 piFileString += line;
2003 qDebug("readline: %s ", line.latin1()); 2017 qDebug("readline: %s ", line.latin1());
2004 setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 2018 setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2005 2019
2006 } 2020 }
2007 if ( piTime.elapsed () < 3000 ) { 2021 if ( piTime.elapsed () < 3000 ) {
2008 // wait for more 2022 // wait for more
2009 qDebug("waitformore "); 2023 qDebug("waitformore ");
2010 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 2024 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2011 return; 2025 return;
2012 } 2026 }
2013 QString fileName = defaultFileName(); 2027 QString fileName = defaultFileName();
2014 QFile file ( fileName ); 2028 QFile file ( fileName );
2015 if (!file.open( IO_WriteOnly ) ) { 2029 if (!file.open( IO_WriteOnly ) ) {
2016 setCaption( i18n("Error open file for writing!") ); 2030 setCaption( i18n("Error open file for writing!") );
2017 delete mSyncActionDialog; 2031 delete mSyncActionDialog;
@@ -2469,106 +2483,211 @@ void MainWindow::syncPhone()
2469{ 2483{
2470 if ( mCalendarModifiedFlag ) 2484 if ( mCalendarModifiedFlag )
2471 save(); 2485 save();
2472 mView->syncPhone(); 2486 mView->syncPhone();
2473 slotModifiedChanged( true ); 2487 slotModifiedChanged( true );
2474 2488
2475} 2489}
2476 2490
2477void MainWindow::printSel( ) 2491void MainWindow::printSel( )
2478{ 2492{
2479 mView->viewManager()->agendaView()->agenda()->printSelection(); 2493 mView->viewManager()->agendaView()->agenda()->printSelection();
2480} 2494}
2481 2495
2482void MainWindow::printCal() 2496void MainWindow::printCal()
2483{ 2497{
2484 mView->print();//mCp->showDialog(); 2498 mView->print();//mCp->showDialog();
2485} 2499}
2486 2500
2487 2501
2488 2502
2489KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 2503KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2490{ 2504{
2491 mPassWord = pw; 2505 mPassWord = pw;
2492 mSocket = 0; 2506 mSocket = 0;
2507 mSyncActionDialog = 0;
2493}; 2508};
2494 2509
2495void KServerSocket::newConnection ( int socket ) 2510void KServerSocket::newConnection ( int socket )
2496{ 2511{
2497 qDebug("KServerSocket:New connection %d ", socket); 2512 qDebug("KServerSocket:New connection %d ", socket);
2498 if ( mSocket ) { 2513 if ( mSocket ) {
2499 qDebug("KServerSocket::newConnection Socket deleted! "); 2514 qDebug("KServerSocket::newConnection Socket deleted! ");
2500 delete mSocket; 2515 delete mSocket;
2501 mSocket = 0; 2516 mSocket = 0;
2502 } 2517 }
2503 mSocket = new QSocket( this ); 2518 mSocket = new QSocket( this );
2504 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2519 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2505 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2520 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2506 mSocket->setSocket( socket ); 2521 mSocket->setSocket( socket );
2507} 2522}
2508 2523
2509void KServerSocket::discardClient() 2524void KServerSocket::discardClient()
2510{ 2525{
2511 qDebug(" KServerSocket::discardClient()"); 2526 qDebug(" KServerSocket::discardClient()");
2512 if ( mSocket ) { 2527 if ( mSocket ) {
2513 qDebug("delete "); 2528 qDebug("delete ");
2514 delete mSocket; 2529 delete mSocket;
2515 mSocket = 0; 2530 mSocket = 0;
2516 } 2531 }
2517 //emit endConnect(); 2532 //emit endConnect();
2518} 2533}
2519void KServerSocket::readClient() 2534void KServerSocket::readClient()
2520{ 2535{
2521 if ( mSocket == 0 ) { 2536 if ( mSocket == 0 ) {
2522 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2537 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2523 return; 2538 return;
2524 } 2539 }
2525 qDebug("KServerSocket readClient()"); 2540 qDebug("KServerSocket readClient()");
2526 if ( mSocket->canReadLine() ) { 2541 if ( mSocket->canReadLine() ) {
2527 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2542 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2528 qDebug("KServerSocket socket->canReadLine()"); 2543 qDebug("KServerSocket socket->canReadLine()");
2529 if ( tokens[0] == "GET" ) { 2544 if ( tokens[0] == "GET" ) {
2530 if ( tokens[1] == mPassWord ) 2545 if ( tokens[1] == mPassWord )
2531 emit sendFile( mSocket ); 2546 //emit sendFile( mSocket );
2547 send_file();
2532 else { 2548 else {
2533 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 2549 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2534 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2550 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2535 } 2551 }
2536 } 2552 }
2537 if ( tokens[0] == "PUT" ) { 2553 if ( tokens[0] == "PUT" ) {
2538 if ( tokens[1] == mPassWord ) 2554 if ( tokens[1] == mPassWord )
2539 emit getFile( mSocket ); 2555 //emit getFile( mSocket );
2556 get_file();
2540 else { 2557 else {
2541 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2558 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2542 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2559 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2543 } 2560 }
2544 } 2561 }
2545 if ( tokens[0] == "STOP" ) { 2562 if ( tokens[0] == "STOP" ) {
2546 emit endConnect(); 2563 emit endConnect();
2547 } 2564 }
2548 } 2565 }
2549} 2566}
2550 2567
2568void KServerSocket::send_file()
2569{
2570 qDebug("MainWindow::sendFile(QSocket* s) ");
2571 if ( mSyncActionDialog )
2572 delete mSyncActionDialog;
2573 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2574 mSyncActionDialog->setCaption(i18n("Received sync request"));
2575 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog );
2576 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2577 lay->addWidget( label);
2578 lay->setMargin(7);
2579 lay->setSpacing(7);
2580 mSyncActionDialog->setFixedSize( 230, 120);
2581 mSyncActionDialog->show();
2582 qDebug("KSS::saving ... ");
2583 emit saveFile();
2584 qApp->processEvents();
2585 QString fileName = mFileName;
2586 QFile file( fileName );
2587 if (!file.open( IO_ReadOnly ) ) {
2588 delete mSyncActionDialog;
2589 mSyncActionDialog = 0;
2590 qDebug("KSS::error open file ");
2591 mSocket->close();
2592 if ( mSocket->state() == QSocket::Idle )
2593 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2594 return ;
2595
2596 }
2597 mSyncActionDialog->setCaption( i18n("Sending file...") );
2598 QTextStream ts( &file );
2599 ts.setCodec( QTextCodec::codecForName("utf8") );
2600 QTextStream os( mSocket );
2601 os.setCodec( QTextCodec::codecForName("utf8") );
2602 //os.setEncoding( QTextStream::UnicodeUTF8 );
2603 while ( ! ts.atEnd() ) {
2604 os << ts.readLine() << "\n";
2605 }
2606 //os << ts.read();
2607 file.close();
2608 mSyncActionDialog->setCaption( i18n("Waiting to get back synced file") );
2609 qDebug("file sent ");
2610 mSocket->close();
2611 if ( mSocket->state() == QSocket::Idle )
2612 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2613}
2614void KServerSocket::get_file()
2615{
2616 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2617
2618 piTime.start();
2619 piFileString = "";
2620 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2621}
2622
2623
2624void KServerSocket::readBackFileFromSocket()
2625{
2626 qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2627 while ( mSocket->canReadLine () ) {
2628 piTime.restart();
2629 QString line = mSocket->readLine ();
2630 piFileString += line;
2631 qDebug("readline: %s ", line.latin1());
2632 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2633
2634 }
2635 if ( piTime.elapsed () < 3000 ) {
2636 // wait for more
2637 qDebug("waitformore ");
2638 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2639 return;
2640 }
2641 QString fileName = mFileName;
2642 QFile file ( fileName );
2643 if (!file.open( IO_WriteOnly ) ) {
2644 delete mSyncActionDialog;
2645 mSyncActionDialog = 0;
2646 qDebug("error open cal file ");
2647 piFileString = "";
2648 emit file_received( false );
2649 return ;
2650
2651 }
2652
2653 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2654 QTextStream ts ( &file );
2655 ts.setCodec( QTextCodec::codecForName("utf8") );
2656 qDebug("finish ");
2657 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2658 ts << piFileString;
2659 mSocket->close();
2660 if ( mSocket->state() == QSocket::Idle )
2661 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2662 file.close();
2663 delete mSyncActionDialog;
2664 mSyncActionDialog = 0;
2665 piFileString = "";
2666 emit file_received( true );
2667
2668}
2669
2551KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 2670KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2552{ 2671{
2553 mPassWord = password; 2672 mPassWord = password;
2554 mSocket = 0; 2673 mSocket = 0;
2555 mPort = port; 2674 mPort = port;
2556 mHost = host; 2675 mHost = host;
2557 2676
2558 mRetVal = false; 2677 mRetVal = false;
2559 mTimerSocket = new QTimer ( this ); 2678 mTimerSocket = new QTimer ( this );
2560 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 2679 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2561} 2680}
2562void KCommandSocket::readFile( QString fn ) 2681void KCommandSocket::readFile( QString fn )
2563{ 2682{
2564 if ( !mSocket ) { 2683 if ( !mSocket ) {
2565 mSocket = new QSocket( this ); 2684 mSocket = new QSocket( this );
2566 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 2685 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2567 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2686 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2568 } 2687 }
2569 mFileString = ""; 2688 mFileString = "";
2570 mFileName = fn; 2689 mFileName = fn;
2571 mFirst = true; 2690 mFirst = true;
2572 mSocket->connectToHost( mHost, mPort ); 2691 mSocket->connectToHost( mHost, mPort );
2573 QTextStream os( mSocket ); 2692 QTextStream os( mSocket );
2574 os.setEncoding( QTextStream::UnicodeUTF8 ); 2693 os.setEncoding( QTextStream::UnicodeUTF8 );
@@ -2616,33 +2735,33 @@ void KCommandSocket::readFileFromSocket()
2616 return ; 2735 return ;
2617 2736
2618 } 2737 }
2619 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2738 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2620 QTextStream ts ( &file ); 2739 QTextStream ts ( &file );
2621 ts.setCodec( QTextCodec::codecForName("utf8") ); 2740 ts.setCodec( QTextCodec::codecForName("utf8") );
2622 qDebug("finish "); 2741 qDebug("finish ");
2623 ts << mFileString; 2742 ts << mFileString;
2624 file.close(); 2743 file.close();
2625 mFileString = ""; 2744 mFileString = "";
2626 mRetVal = true; 2745 mRetVal = true;
2627 mSocket->close(); 2746 mSocket->close();
2628 // if state is not idle, deleteSocket(); is called via 2747 // if state is not idle, deleteSocket(); is called via
2629 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2748 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2630 if ( mSocket->state() == QSocket::Idle ) 2749 if ( mSocket->state() == QSocket::Idle )
2631 deleteSocket(); 2750 deleteSocket();
2632} 2751}
2633 2752
2634void KCommandSocket::deleteSocket() 2753void KCommandSocket::deleteSocket()
2635{ 2754{
2636 if ( !mSocket) 2755 if ( !mSocket)
2637 return; 2756 return;
2638 if ( mTimerSocket->isActive () ) { 2757 if ( mTimerSocket->isActive () ) {
2639 mTimerSocket->stop(); 2758 mTimerSocket->stop();
2640 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); 2759 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2641 mRetVal = false; 2760 mRetVal = false;
2642 } 2761 }
2643 qDebug("KCommandSocket::deleteSocket() %d", mRetVal); 2762 qDebug("KCommandSocket::deleteSocket() %d", mRetVal);
2644 delete mSocket; 2763 delete mSocket;
2645 mSocket = 0; 2764 mSocket = 0;
2646 emit commandFinished( mRetVal ); 2765 emit commandFinished( mRetVal );
2647} 2766}
2648 2767
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 11a816c..8b76067 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -12,59 +12,70 @@
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 13#include "simplealarmclient.h"
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24#include <qserversocket.h> 24#include <qserversocket.h>
25#include <qsocket.h> 25#include <qsocket.h>
26#include <qnetworkprotocol.h> 26#include <qnetworkprotocol.h>
27 27
28class KServerSocket : public QServerSocket 28class KServerSocket : public QServerSocket
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 31
32public: 32public:
33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
34 34
35 void newConnection ( int socket ) ; 35 void newConnection ( int socket ) ;
36 void setFileName( QString fn ) {mFileName = fn;};
36 37
37signals: 38signals:
38 void sendFile(QSocket*); 39 //void sendFile(QSocket*);
39 void getFile(QSocket*); 40 //void getFile(QSocket*);
41 void file_received( bool );
42 //void file_sent();
43 void saveFile();
40 void endConnect(); 44 void endConnect();
41private slots: 45private slots:
42 void discardClient(); 46 void discardClient();
43 void readClient(); 47 void readClient();
48 void readBackFileFromSocket();
44 private : 49 private :
50 void send_file();
51 void get_file();
52 QDialog* mSyncActionDialog;
45 QSocket* mSocket; 53 QSocket* mSocket;
46 QString mPassWord; 54 QString mPassWord;
55 QString mFileName;
56 QTime piTime;
57 QString piFileString;
47}; 58};
48 59
49class KCommandSocket : public QObject 60class KCommandSocket : public QObject
50{ 61{
51 Q_OBJECT 62 Q_OBJECT
52 63
53public: 64public:
54 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 65 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
55 void readFile( QString ); 66 void readFile( QString );
56 void writeFile( QString ); 67 void writeFile( QString );
57 68
58 69
59signals: 70signals:
60 void commandFinished( bool ); 71 void commandFinished( bool );
61private slots: 72private slots:
62 void startReadFileFromSocket(); 73 void startReadFileFromSocket();
63 void readFileFromSocket(); 74 void readFileFromSocket();
64 void deleteSocket(); 75 void deleteSocket();
65 private : 76 private :
66 QSocket* mSocket; 77 QSocket* mSocket;
67 QString mPassWord; 78 QString mPassWord;
68 Q_UINT16 mPort; 79 Q_UINT16 mPort;
69 QString mHost; 80 QString mHost;
70 QString mFileName; 81 QString mFileName;
@@ -132,49 +143,49 @@ class MainWindow : public QMainWindow
132 void slotSyncMenu( int ); 143 void slotSyncMenu( int );
133 void syncSSH(); 144 void syncSSH();
134 void confSync(); 145 void confSync();
135 void syncSharp(); 146 void syncSharp();
136 void syncPhone(); 147 void syncPhone();
137 void syncLocalFile(); 148 void syncLocalFile();
138 bool syncWithFile( QString, bool ); 149 bool syncWithFile( QString, bool );
139 void quickSyncLocalFile(); 150 void quickSyncLocalFile();
140 151
141 152
142 protected: 153 protected:
143 void displayText( QString, QString); 154 void displayText( QString, QString);
144 void displayFile( QString, QString); 155 void displayFile( QString, QString);
145 156
146 void enableIncidenceActions( bool ); 157 void enableIncidenceActions( bool );
147 158
148 private slots: 159 private slots:
149 QSocket* piSocket; 160 QSocket* piSocket;
150 QString piFileString; 161 QString piFileString;
151 QTime piTime; 162 QTime piTime;
152 void deleteCommandSocket(bool); 163 void deleteCommandSocket(bool);
153 void deleteCommandSocketFinish(); 164 void deleteCommandSocketFinish();
154 void fillSyncMenu(); 165 void fillSyncMenu();
155 void sendFile(QSocket* s); 166 void sendFile(QSocket* s);
156 void getFile(QSocket* socket); 167 void getFile( bool );
157 void readFileFromSocket(); 168 void readFileFromSocket();
158 void readBackFileFromSocket(); 169 void readBackFileFromSocket();
159 void endConnect(); 170 void endConnect();
160 private: 171 private:
161 //QTimer* mTimerCommandSocket; 172 //QTimer* mTimerCommandSocket;
162 QString mPassWordPiSync; 173 QString mPassWordPiSync;
163 KCommandSocket* mCommandSocket; 174 KCommandSocket* mCommandSocket;
164 QSocket* mCommandSocketFinish; 175 QSocket* mCommandSocketFinish;
165 KServerSocket * mServerSocket; 176 KServerSocket * mServerSocket;
166 bool mClosed; 177 bool mClosed;
167 void saveOnClose(); 178 void saveOnClose();
168 int mCurrentSyncProfile; 179 int mCurrentSyncProfile;
169 void enableQuick(); 180 void enableQuick();
170 void performQuick(); 181 void performQuick();
171 void performQuickQuick(); 182 void performQuickQuick();
172 void syncRemote( KSyncProfile* , bool ask = true); 183 void syncRemote( KSyncProfile* , bool ask = true);
173 bool mFlagKeyPressed; 184 bool mFlagKeyPressed;
174 bool mBlockAtStartup; 185 bool mBlockAtStartup;
175 QPEToolBar *iconToolBar; 186 QPEToolBar *iconToolBar;
176 void initActions(); 187 void initActions();
177 void setDefaultPreferences(); 188 void setDefaultPreferences();
178 void keyPressEvent ( QKeyEvent * ) ; 189 void keyPressEvent ( QKeyEvent * ) ;
179 void keyReleaseEvent ( QKeyEvent * ) ; 190 void keyReleaseEvent ( QKeyEvent * ) ;
180 QPopupMenu *configureToolBarMenu; 191 QPopupMenu *configureToolBarMenu;