summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp23
-rw-r--r--korganizer/mainwindow.h1
2 files changed, 15 insertions, 9 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index fe7e6d3..b7176a1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2337,299 +2337,304 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject
2337 2337
2338void KServerSocket::newConnection ( int socket ) 2338void KServerSocket::newConnection ( int socket )
2339{ 2339{
2340 // qDebug("KServerSocket:New connection %d ", socket); 2340 // qDebug("KServerSocket:New connection %d ", socket);
2341 if ( mSocket ) { 2341 if ( mSocket ) {
2342 qDebug("KServerSocket::newConnection Socket deleted! "); 2342 qDebug("KServerSocket::newConnection Socket deleted! ");
2343 delete mSocket; 2343 delete mSocket;
2344 mSocket = 0; 2344 mSocket = 0;
2345 } 2345 }
2346 mSocket = new QSocket( this ); 2346 mSocket = new QSocket( this );
2347 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2347 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2348 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2348 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2349 mSocket->setSocket( socket ); 2349 mSocket->setSocket( socket );
2350} 2350}
2351 2351
2352void KServerSocket::discardClient() 2352void KServerSocket::discardClient()
2353{ 2353{
2354 //qDebug(" KServerSocket::discardClient()"); 2354 //qDebug(" KServerSocket::discardClient()");
2355 if ( mSocket ) { 2355 if ( mSocket ) {
2356 delete mSocket; 2356 delete mSocket;
2357 mSocket = 0; 2357 mSocket = 0;
2358 } 2358 }
2359 //emit endConnect(); 2359 //emit endConnect();
2360} 2360}
2361void KServerSocket::readClient() 2361void KServerSocket::readClient()
2362{ 2362{
2363 if ( mSocket == 0 ) { 2363 if ( mSocket == 0 ) {
2364 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2364 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2365 return; 2365 return;
2366 } 2366 }
2367 //qDebug("KServerSocket readClient()"); 2367 //qDebug("KServerSocket readClient()");
2368 if ( mSocket->canReadLine() ) { 2368 if ( mSocket->canReadLine() ) {
2369 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2369 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2370 if ( tokens[0] == "GET" ) { 2370 if ( tokens[0] == "GET" ) {
2371 if ( tokens[1] == mPassWord ) 2371 if ( tokens[1] == mPassWord )
2372 //emit sendFile( mSocket ); 2372 //emit sendFile( mSocket );
2373 send_file(); 2373 send_file();
2374 else { 2374 else {
2375 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 2375 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2376 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2376 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2377 } 2377 }
2378 } 2378 }
2379 if ( tokens[0] == "PUT" ) { 2379 if ( tokens[0] == "PUT" ) {
2380 if ( tokens[1] == mPassWord ) 2380 if ( tokens[1] == mPassWord )
2381 //emit getFile( mSocket ); 2381 //emit getFile( mSocket );
2382 get_file(); 2382 get_file();
2383 else { 2383 else {
2384 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2384 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2385 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2385 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2386 } 2386 }
2387 } 2387 }
2388 if ( tokens[0] == "STOP" ) { 2388 if ( tokens[0] == "STOP" ) {
2389 //emit endConnect(); 2389 //emit endConnect();
2390 end_connect(); 2390 end_connect();
2391 } 2391 }
2392 } 2392 }
2393} 2393}
2394void KServerSocket::end_connect() 2394void KServerSocket::end_connect()
2395{ 2395{
2396 delete mSyncActionDialog; 2396 delete mSyncActionDialog;
2397 mSyncActionDialog = 0; 2397 mSyncActionDialog = 0;
2398} 2398}
2399void KServerSocket::send_file() 2399void KServerSocket::send_file()
2400{ 2400{
2401 //qDebug("MainWindow::sendFile(QSocket* s) "); 2401 //qDebug("MainWindow::sendFile(QSocket* s) ");
2402 if ( mSyncActionDialog ) 2402 if ( mSyncActionDialog )
2403 delete mSyncActionDialog; 2403 delete mSyncActionDialog;
2404 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 2404 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2405 mSyncActionDialog->setCaption(i18n("Received sync request")); 2405 mSyncActionDialog->setCaption(i18n("Received sync request"));
2406 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); 2406 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog );
2407 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 2407 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2408 lay->addWidget( label); 2408 lay->addWidget( label);
2409 lay->setMargin(7); 2409 lay->setMargin(7);
2410 lay->setSpacing(7); 2410 lay->setSpacing(7);
2411 mSyncActionDialog->setFixedSize( 230, 120); 2411 mSyncActionDialog->setFixedSize( 230, 120);
2412 mSyncActionDialog->show(); 2412 mSyncActionDialog->show();
2413 qDebug("KSS::saving ... "); 2413 qDebug("KSS::saving ... ");
2414 emit saveFile(); 2414 emit saveFile();
2415 qApp->processEvents(); 2415 qApp->processEvents();
2416 QString fileName = mFileName; 2416 QString fileName = mFileName;
2417 QFile file( fileName ); 2417 QFile file( fileName );
2418 if (!file.open( IO_ReadOnly ) ) { 2418 if (!file.open( IO_ReadOnly ) ) {
2419 delete mSyncActionDialog; 2419 delete mSyncActionDialog;
2420 mSyncActionDialog = 0; 2420 mSyncActionDialog = 0;
2421 qDebug("KSS::error open file "); 2421 qDebug("KSS::error open file ");
2422 mSocket->close(); 2422 mSocket->close();
2423 if ( mSocket->state() == QSocket::Idle ) 2423 if ( mSocket->state() == QSocket::Idle )
2424 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2424 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2425 return ; 2425 return ;
2426 2426
2427 } 2427 }
2428 mSyncActionDialog->setCaption( i18n("Sending file...") ); 2428 mSyncActionDialog->setCaption( i18n("Sending file...") );
2429 QTextStream ts( &file ); 2429 QTextStream ts( &file );
2430 ts.setCodec( QTextCodec::codecForName("utf8") ); 2430 ts.setCodec( QTextCodec::codecForName("utf8") );
2431 QTextStream os( mSocket ); 2431 QTextStream os( mSocket );
2432 os.setCodec( QTextCodec::codecForName("utf8") ); 2432 os.setCodec( QTextCodec::codecForName("utf8") );
2433 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2433 //os.setEncoding( QTextStream::UnicodeUTF8 );
2434 while ( ! ts.atEnd() ) { 2434 while ( ! ts.atEnd() ) {
2435 os << ts.readLine() << "\n"; 2435 os << ts.readLine() << "\n";
2436 } 2436 }
2437 //os << ts.read(); 2437 //os << ts.read();
2438 file.close(); 2438 file.close();
2439 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 2439 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
2440 mSocket->close(); 2440 mSocket->close();
2441 if ( mSocket->state() == QSocket::Idle ) 2441 if ( mSocket->state() == QSocket::Idle )
2442 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2442 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2443} 2443}
2444void KServerSocket::get_file() 2444void KServerSocket::get_file()
2445{ 2445{
2446 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 2446 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2447 2447
2448 piTime.start(); 2448 piTime.start();
2449 piFileString = ""; 2449 piFileString = "";
2450 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 2450 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2451} 2451}
2452 2452
2453 2453
2454void KServerSocket::readBackFileFromSocket() 2454void KServerSocket::readBackFileFromSocket()
2455{ 2455{
2456 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 2456 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2457 while ( mSocket->canReadLine () ) { 2457 while ( mSocket->canReadLine () ) {
2458 piTime.restart(); 2458 piTime.restart();
2459 QString line = mSocket->readLine (); 2459 QString line = mSocket->readLine ();
2460 piFileString += line; 2460 piFileString += line;
2461 //qDebug("readline: %s ", line.latin1()); 2461 //qDebug("readline: %s ", line.latin1());
2462 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 2462 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2463 2463
2464 } 2464 }
2465 if ( piTime.elapsed () < 3000 ) { 2465 if ( piTime.elapsed () < 3000 ) {
2466 // wait for more 2466 // wait for more
2467 //qDebug("waitformore "); 2467 //qDebug("waitformore ");
2468 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 2468 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2469 return; 2469 return;
2470 } 2470 }
2471 QString fileName = mFileName; 2471 QString fileName = mFileName;
2472 QFile file ( fileName ); 2472 QFile file ( fileName );
2473 if (!file.open( IO_WriteOnly ) ) { 2473 if (!file.open( IO_WriteOnly ) ) {
2474 delete mSyncActionDialog; 2474 delete mSyncActionDialog;
2475 mSyncActionDialog = 0; 2475 mSyncActionDialog = 0;
2476 qDebug("error open cal file "); 2476 qDebug("error open cal file ");
2477 piFileString = ""; 2477 piFileString = "";
2478 emit file_received( false ); 2478 emit file_received( false );
2479 return ; 2479 return ;
2480 2480
2481 } 2481 }
2482 2482
2483 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2483 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2484 QTextStream ts ( &file ); 2484 QTextStream ts ( &file );
2485 ts.setCodec( QTextCodec::codecForName("utf8") ); 2485 ts.setCodec( QTextCodec::codecForName("utf8") );
2486 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 2486 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2487 ts << piFileString; 2487 ts << piFileString;
2488 mSocket->close(); 2488 mSocket->close();
2489 if ( mSocket->state() == QSocket::Idle ) 2489 if ( mSocket->state() == QSocket::Idle )
2490 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2490 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2491 file.close(); 2491 file.close();
2492 delete mSyncActionDialog; 2492 delete mSyncActionDialog;
2493 mSyncActionDialog = 0; 2493 mSyncActionDialog = 0;
2494 piFileString = ""; 2494 piFileString = "";
2495 emit file_received( true ); 2495 emit file_received( true );
2496 2496
2497} 2497}
2498 2498
2499KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 2499KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2500{ 2500{
2501 mPassWord = password; 2501 mPassWord = password;
2502 mSocket = 0; 2502 mSocket = 0;
2503 mPort = port; 2503 mPort = port;
2504 mHost = host; 2504 mHost = host;
2505 2505
2506 mRetVal = false; 2506 mRetVal = false;
2507 mTimerSocket = new QTimer ( this ); 2507 mTimerSocket = new QTimer ( this );
2508 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 2508 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2509} 2509}
2510void KCommandSocket::readFile( QString fn ) 2510void KCommandSocket::readFile( QString fn )
2511{ 2511{
2512 if ( !mSocket ) { 2512 if ( !mSocket ) {
2513 mSocket = new QSocket( this ); 2513 mSocket = new QSocket( this );
2514 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 2514 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2515 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2515 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2516 } 2516 }
2517 mFileString = ""; 2517 mFileString = "";
2518 mFileName = fn; 2518 mFileName = fn;
2519 mFirst = true; 2519 mFirst = true;
2520 mSocket->connectToHost( mHost, mPort ); 2520 mSocket->connectToHost( mHost, mPort );
2521 QTextStream os( mSocket ); 2521 QTextStream os( mSocket );
2522 os.setEncoding( QTextStream::UnicodeUTF8 ); 2522 os.setEncoding( QTextStream::UnicodeUTF8 );
2523 os << "GET " << mPassWord << "\r\n"; 2523 os << "GET " << mPassWord << "\r\n";
2524 mTimerSocket->start( 10000 ); 2524 mTimerSocket->start( 10000 );
2525} 2525}
2526 2526
2527void KCommandSocket::writeFile( QString fileName ) 2527void KCommandSocket::writeFile( QString fileName )
2528{ 2528{
2529 QFile file2( fileName );
2530 if (!file2.open( IO_ReadOnly ) ) {
2531 mRetVal= false;
2532 deleteSocket();
2533 return ;
2534
2535 }
2536 if ( !mSocket ) { 2529 if ( !mSocket ) {
2537 mSocket = new QSocket( this ); 2530 mSocket = new QSocket( this );
2538 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2531 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2532 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
2539 } 2533 }
2534 mFileName = fileName ;
2540 mSocket->connectToHost( mHost, mPort ); 2535 mSocket->connectToHost( mHost, mPort );
2536}
2537void KCommandSocket::writeFileToSocket()
2538{
2539 QFile file2( mFileName );
2540 if (!file2.open( IO_ReadOnly ) ) {
2541 mRetVal= false;
2542 mSocket->close();
2543 if ( mSocket->state() == QSocket::Idle )
2544 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2545 return ;
2546 }
2541 QTextStream ts2( &file2 ); 2547 QTextStream ts2( &file2 );
2542 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2548 ts2.setCodec( QTextCodec::codecForName("utf8") );
2543 QTextStream os2( mSocket ); 2549 QTextStream os2( mSocket );
2544 os2.setCodec( QTextCodec::codecForName("utf8") ); 2550 os2.setCodec( QTextCodec::codecForName("utf8") );
2545 os2 << "PUT " << mPassWord << "\r\n";; 2551 os2 << "PUT " << mPassWord << "\r\n";;
2546 while ( ! ts2.atEnd() ) { 2552 while ( ! ts2.atEnd() ) {
2547 os2 << ts2.readLine() << "\n"; 2553 os2 << ts2.readLine() << "\n";
2548 } 2554 }
2549 mRetVal= true; 2555 mRetVal= true;
2556 file2.close();
2550 mSocket->close(); 2557 mSocket->close();
2551 if ( mSocket->state() == QSocket::Idle ) 2558 if ( mSocket->state() == QSocket::Idle )
2552 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2559 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2553 file2.close();
2554} 2560}
2555
2556void KCommandSocket::sendStop() 2561void KCommandSocket::sendStop()
2557{ 2562{
2558 if ( !mSocket ) { 2563 if ( !mSocket ) {
2559 mSocket = new QSocket( this ); 2564 mSocket = new QSocket( this );
2560 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2565 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2561 } 2566 }
2562 mSocket->connectToHost( mHost, mPort ); 2567 mSocket->connectToHost( mHost, mPort );
2563 QTextStream os2( mSocket ); 2568 QTextStream os2( mSocket );
2564 os2.setCodec( QTextCodec::codecForName("utf8") ); 2569 os2.setCodec( QTextCodec::codecForName("utf8") );
2565 os2 << "STOP\r\n"; 2570 os2 << "STOP\r\n";
2566 mRetVal= true; 2571 mRetVal= true;
2567 mSocket->close(); 2572 mSocket->close();
2568 if ( mSocket->state() == QSocket::Idle ) 2573 if ( mSocket->state() == QSocket::Idle )
2569 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2574 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2570} 2575}
2571 2576
2572void KCommandSocket::startReadFileFromSocket() 2577void KCommandSocket::startReadFileFromSocket()
2573{ 2578{
2574 if ( ! mFirst ) 2579 if ( ! mFirst )
2575 return; 2580 return;
2576 mFirst = false; 2581 mFirst = false;
2577 mTimerSocket->stop(); 2582 mTimerSocket->stop();
2578 mFileString = ""; 2583 mFileString = "";
2579 mTime.start(); 2584 mTime.start();
2580 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 2585 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
2581 2586
2582} 2587}
2583void KCommandSocket::readFileFromSocket() 2588void KCommandSocket::readFileFromSocket()
2584{ 2589{
2585 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 2590 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
2586 while ( mSocket->canReadLine () ) { 2591 while ( mSocket->canReadLine () ) {
2587 mTime.restart(); 2592 mTime.restart();
2588 QString line = mSocket->readLine (); 2593 QString line = mSocket->readLine ();
2589 mFileString += line; 2594 mFileString += line;
2590 //qDebug("readline: %s ", line.latin1()); 2595 //qDebug("readline: %s ", line.latin1());
2591 } 2596 }
2592 if ( mTime.elapsed () < 3000 ) { 2597 if ( mTime.elapsed () < 3000 ) {
2593 // wait for more 2598 // wait for more
2594 //qDebug("waitformore "); 2599 //qDebug("waitformore ");
2595 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 2600 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
2596 return; 2601 return;
2597 } 2602 }
2598 QString fileName = mFileName; 2603 QString fileName = mFileName;
2599 QFile file ( fileName ); 2604 QFile file ( fileName );
2600 if (!file.open( IO_WriteOnly ) ) { 2605 if (!file.open( IO_WriteOnly ) ) {
2601 mFileString = ""; 2606 mFileString = "";
2602 mRetVal = false; 2607 mRetVal = false;
2603 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2608 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2604 deleteSocket(); 2609 deleteSocket();
2605 return ; 2610 return ;
2606 2611
2607 } 2612 }
2608 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2613 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2609 QTextStream ts ( &file ); 2614 QTextStream ts ( &file );
2610 ts.setCodec( QTextCodec::codecForName("utf8") ); 2615 ts.setCodec( QTextCodec::codecForName("utf8") );
2611 ts << mFileString; 2616 ts << mFileString;
2612 file.close(); 2617 file.close();
2613 mFileString = ""; 2618 mFileString = "";
2614 mRetVal = true; 2619 mRetVal = true;
2615 mSocket->close(); 2620 mSocket->close();
2616 // if state is not idle, deleteSocket(); is called via 2621 // if state is not idle, deleteSocket(); is called via
2617 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2622 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2618 if ( mSocket->state() == QSocket::Idle ) 2623 if ( mSocket->state() == QSocket::Idle )
2619 deleteSocket(); 2624 deleteSocket();
2620} 2625}
2621 2626
2622void KCommandSocket::deleteSocket() 2627void KCommandSocket::deleteSocket()
2623{ 2628{
2624 if ( mTimerSocket->isActive () ) { 2629 if ( mTimerSocket->isActive () ) {
2625 mTimerSocket->stop(); 2630 mTimerSocket->stop();
2626 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 2631 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2627 mRetVal = false; 2632 mRetVal = false;
2628 } 2633 }
2629 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 2634 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
2630 if ( mSocket) 2635 if ( mSocket)
2631 delete mSocket; 2636 delete mSocket;
2632 mSocket = 0; 2637 mSocket = 0;
2633 emit commandFinished( this, mRetVal ); 2638 emit commandFinished( this, mRetVal );
2634} 2639}
2635 2640
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index f8b2334..90b3a88 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,209 +1,210 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qsocket.h> 8#include <qsocket.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
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 void setFileName( QString fn ) {mFileName = fn;};
37 37
38signals: 38signals:
39 //void sendFile(QSocket*); 39 //void sendFile(QSocket*);
40 //void getFile(QSocket*); 40 //void getFile(QSocket*);
41 void file_received( bool ); 41 void file_received( bool );
42 //void file_sent(); 42 //void file_sent();
43 void saveFile(); 43 void saveFile();
44 void endConnect(); 44 void endConnect();
45private slots: 45private slots:
46 void discardClient(); 46 void discardClient();
47 void readClient(); 47 void readClient();
48 void readBackFileFromSocket(); 48 void readBackFileFromSocket();
49 private : 49 private :
50 void send_file(); 50 void send_file();
51 void get_file(); 51 void get_file();
52 void end_connect(); 52 void end_connect();
53 QDialog* mSyncActionDialog; 53 QDialog* mSyncActionDialog;
54 QSocket* mSocket; 54 QSocket* mSocket;
55 QString mPassWord; 55 QString mPassWord;
56 QString mFileName; 56 QString mFileName;
57 QTime piTime; 57 QTime piTime;
58 QString piFileString; 58 QString piFileString;
59}; 59};
60 60
61class KCommandSocket : public QObject 61class KCommandSocket : public QObject
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 64
65public: 65public:
66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
67 void readFile( QString ); 67 void readFile( QString );
68 void writeFile( QString ); 68 void writeFile( QString );
69 void sendStop(); 69 void sendStop();
70 70
71 71
72signals: 72signals:
73 void commandFinished( KCommandSocket*, bool ); 73 void commandFinished( KCommandSocket*, bool );
74private slots: 74private slots:
75 void startReadFileFromSocket(); 75 void startReadFileFromSocket();
76 void readFileFromSocket(); 76 void readFileFromSocket();
77 void deleteSocket(); 77 void deleteSocket();
78 void writeFileToSocket();
78 private : 79 private :
79 QSocket* mSocket; 80 QSocket* mSocket;
80 QString mPassWord; 81 QString mPassWord;
81 Q_UINT16 mPort; 82 Q_UINT16 mPort;
82 QString mHost; 83 QString mHost;
83 QString mFileName; 84 QString mFileName;
84 QTimer* mTimerSocket; 85 QTimer* mTimerSocket;
85 bool mRetVal; 86 bool mRetVal;
86 QTime mTime; 87 QTime mTime;
87 QString mFileString; 88 QString mFileString;
88 bool mFirst; 89 bool mFirst;
89}; 90};
90 91
91namespace KCal { 92namespace KCal {
92class CalendarLocal; 93class CalendarLocal;
93} 94}
94 95
95using namespace KCal; 96using namespace KCal;
96 97
97class MainWindow : public QMainWindow 98class MainWindow : public QMainWindow
98{ 99{
99 Q_OBJECT 100 Q_OBJECT
100 public: 101 public:
101 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 102 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
102 ~MainWindow(); 103 ~MainWindow();
103 public slots: 104 public slots:
104 virtual void showMaximized (); 105 virtual void showMaximized ();
105 void configureAgenda( int ); 106 void configureAgenda( int );
106 void recieve( const QCString& msg, const QByteArray& data ); 107 void recieve( const QCString& msg, const QByteArray& data );
107 static QString defaultFileName(); 108 static QString defaultFileName();
108 static QString resourcePath(); 109 static QString resourcePath();
109 protected slots: 110 protected slots:
110 void setCaptionToDates(); 111 void setCaptionToDates();
111 int ringSync(); 112 int ringSync();
112 void multiSync( bool askforPrefs = false ); 113 void multiSync( bool askforPrefs = false );
113 void about(); 114 void about();
114 void licence(); 115 void licence();
115 void faq(); 116 void faq();
116 void usertrans(); 117 void usertrans();
117 void features(); 118 void features();
118 void synchowto(); 119 void synchowto();
119 void whatsNew(); 120 void whatsNew();
120 void keyBindings(); 121 void keyBindings();
121 void aboutAutoSaving();; 122 void aboutAutoSaving();;
122 void aboutKnownBugs(); 123 void aboutKnownBugs();
123 124
124 void processIncidenceSelection( Incidence * ); 125 void processIncidenceSelection( Incidence * );
125 126
126 void importQtopia(); 127 void importQtopia();
127 void importBday(); 128 void importBday();
128 void importOL(); 129 void importOL();
129 void importIcal(); 130 void importIcal();
130 void importFile( QString, bool ); 131 void importFile( QString, bool );
131 void quickImportIcal(); 132 void quickImportIcal();
132 133
133 void slotModifiedChanged( bool ); 134 void slotModifiedChanged( bool );
134 135
135 void save(); 136 void save();
136 void configureToolBar( int ); 137 void configureToolBar( int );
137 void printSel(); 138 void printSel();
138 void printCal(); 139 void printCal();
139 void saveCalendar(); 140 void saveCalendar();
140 void loadCalendar(); 141 void loadCalendar();
141 void exportVCalendar(); 142 void exportVCalendar();
142 void fillFilterMenu(); 143 void fillFilterMenu();
143 void selectFilter( int ); 144 void selectFilter( int );
144 145
145 void slotSyncMenu( int ); 146 void slotSyncMenu( int );
146 void syncSSH(); 147 void syncSSH();
147 void confSync(); 148 void confSync();
148 void syncSharp(); 149 void syncSharp();
149 void syncPhone(); 150 void syncPhone();
150 void syncPi(); 151 void syncPi();
151 void syncLocalFile(); 152 void syncLocalFile();
152 bool syncWithFile( QString, bool ); 153 bool syncWithFile( QString, bool );
153 void quickSyncLocalFile(); 154 void quickSyncLocalFile();
154 155
155 156
156 protected: 157 protected:
157 void displayText( QString, QString); 158 void displayText( QString, QString);
158 void displayFile( QString, QString); 159 void displayFile( QString, QString);
159 160
160 void enableIncidenceActions( bool ); 161 void enableIncidenceActions( bool );
161 162
162 private slots: 163 private slots:
163 QSocket* piSocket; 164 QSocket* piSocket;
164 QString piFileString; 165 QString piFileString;
165 QTime piTime; 166 QTime piTime;
166 void deleteCommandSocket(KCommandSocket* s, bool success); 167 void deleteCommandSocket(KCommandSocket* s, bool success);
167 void deleteCommandSocketFinish(KCommandSocket* s, bool success); 168 void deleteCommandSocketFinish(KCommandSocket* s, bool success);
168 void fillSyncMenu(); 169 void fillSyncMenu();
169 void getFile( bool ); 170 void getFile( bool );
170 void readFileFromSocket(); 171 void readFileFromSocket();
171 private: 172 private:
172 //QTimer* mTimerCommandSocket; 173 //QTimer* mTimerCommandSocket;
173 QString mPassWordPiSync; 174 QString mPassWordPiSync;
174 KServerSocket * mServerSocket; 175 KServerSocket * mServerSocket;
175 bool mClosed; 176 bool mClosed;
176 void saveOnClose(); 177 void saveOnClose();
177 int mCurrentSyncProfile; 178 int mCurrentSyncProfile;
178 void enableQuick(); 179 void enableQuick();
179 void performQuickQuick(); 180 void performQuickQuick();
180 void syncRemote( KSyncProfile* , bool ask = true); 181 void syncRemote( KSyncProfile* , bool ask = true);
181 bool mFlagKeyPressed; 182 bool mFlagKeyPressed;
182 bool mBlockAtStartup; 183 bool mBlockAtStartup;
183 QPEToolBar *iconToolBar; 184 QPEToolBar *iconToolBar;
184 void initActions(); 185 void initActions();
185 void setDefaultPreferences(); 186 void setDefaultPreferences();
186 void keyPressEvent ( QKeyEvent * ) ; 187 void keyPressEvent ( QKeyEvent * ) ;
187 void keyReleaseEvent ( QKeyEvent * ) ; 188 void keyReleaseEvent ( QKeyEvent * ) ;
188 QPopupMenu *configureToolBarMenu; 189 QPopupMenu *configureToolBarMenu;
189 QPopupMenu *selectFilterMenu; 190 QPopupMenu *selectFilterMenu;
190 QPopupMenu *configureAgendaMenu, *syncMenu; 191 QPopupMenu *configureAgendaMenu, *syncMenu;
191 CalendarLocal *mCalendar; 192 CalendarLocal *mCalendar;
192 CalendarView *mView; 193 CalendarView *mView;
193 QString getPassword(); 194 QString getPassword();
194 QAction *mNewSubTodoAction; 195 QAction *mNewSubTodoAction;
195 196
196 QAction *mShowAction; 197 QAction *mShowAction;
197 QAction *mEditAction; 198 QAction *mEditAction;
198 QAction *mDeleteAction; 199 QAction *mDeleteAction;
199 void closeEvent( QCloseEvent* ce ); 200 void closeEvent( QCloseEvent* ce );
200 SimpleAlarmClient mAlarmClient; 201 SimpleAlarmClient mAlarmClient;
201 QTimer mSaveTimer; 202 QTimer mSaveTimer;
202 bool mBlockSaveFlag; 203 bool mBlockSaveFlag;
203 bool mCalendarModifiedFlag; 204 bool mCalendarModifiedFlag;
204 QPixmap loadPixmap( QString ); 205 QPixmap loadPixmap( QString );
205 QDialog * mSyncActionDialog; 206 QDialog * mSyncActionDialog;
206}; 207};
207 208
208 209
209#endif 210#endif