summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2005-11-25 21:00:35 (UTC)
committer zautrix <zautrix>2005-11-25 21:00:35 (UTC)
commit81d012860ea3d5d17d0e9cf16ec992baa83efbbf (patch) (unidiff)
tree2e5ce0b81f1700f9c6dc60a8411029cd194e45a1 /libkdepim/ksyncmanager.cpp
parent2468bddcb380d8621d5bb49b69b3492d90562d93 (diff)
downloadkdepimpi-81d012860ea3d5d17d0e9cf16ec992baa83efbbf.zip
kdepimpi-81d012860ea3d5d17d0e9cf16ec992baa83efbbf.tar.gz
kdepimpi-81d012860ea3d5d17d0e9cf16ec992baa83efbbf.tar.bz2
sync
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d2cb71b..e1b15d2 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1648,131 +1648,131 @@ void KCommandSocket::writeFileToSocket()
1648 mConnectProgress.blockSignals( false ); 1648 mConnectProgress.blockSignals( false );
1649} 1649}
1650void KCommandSocket::sendStop() 1650void KCommandSocket::sendStop()
1651{ 1651{
1652 if ( !mSocket ) { 1652 if ( !mSocket ) {
1653 mSocket = new QSocket( this ); 1653 mSocket = new QSocket( this );
1654 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1654 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1655 } 1655 }
1656 mSocket->connectToHost( mHost, mPort ); 1656 mSocket->connectToHost( mHost, mPort );
1657 QTextStream os2( mSocket ); 1657 QTextStream os2( mSocket );
1658 os2.setEncoding( QTextStream::Latin1 ); 1658 os2.setEncoding( QTextStream::Latin1 );
1659 os2 << "STOP\r\n\r\n"; 1659 os2 << "STOP\r\n\r\n";
1660 mSocket->close(); 1660 mSocket->close();
1661 if ( mSocket->state() == QSocket::Idle ) 1661 if ( mSocket->state() == QSocket::Idle )
1662 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1662 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1663} 1663}
1664 1664
1665void KCommandSocket::startReadFileFromSocket() 1665void KCommandSocket::startReadFileFromSocket()
1666{ 1666{
1667 if ( ! mFirst ) 1667 if ( ! mFirst )
1668 return; 1668 return;
1669 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1669 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1670 mFirst = false; 1670 mFirst = false;
1671 mFileString = ""; 1671 mFileString = "";
1672 mTime.start(); 1672 mTime.start();
1673 mFirstLine = true; 1673 mFirstLine = true;
1674 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1674 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1675 1675
1676} 1676}
1677void KCommandSocket::readFileFromSocket() 1677void KCommandSocket::readFileFromSocket()
1678{ 1678{
1679 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1679 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1680 while ( mSocket->canReadLine () ) { 1680 while ( mSocket->canReadLine () ) {
1681 mTime.restart(); 1681 mTime.restart();
1682 QString line = mSocket->readLine (); 1682 QString line = mSocket->readLine ();
1683 if ( mFirstLine ) { 1683 if ( mFirstLine ) {
1684 mFirstLine = false; 1684 mFirstLine = false;
1685 if ( line.left( 6 ) == "ERROR_" ) { 1685 if ( line.left( 6 ) == "ERROR_" ) {
1686 mTimerSocket->stop(); 1686 mTimerSocket->stop();
1687 mConnectCount = -1; 1687 mConnectCount = -1;
1688 if ( line.left( 8 ) == "ERROR_PW" ) { 1688 if ( line.left( 8 ) == "ERROR_PW" ) {
1689 mRetVal = errorPW; 1689 mRetVal = errorPW;
1690 deleteSocket(); 1690 deleteSocket();
1691 return ; 1691 return ;
1692 } 1692 }
1693 if ( line.left( 8 ) == "ERROR_CA" ) { 1693 if ( line.left( 8 ) == "ERROR_CA" ) {
1694 mRetVal = errorCA; 1694 mRetVal = errorCA;
1695 deleteSocket(); 1695 deleteSocket();
1696 return ; 1696 return ;
1697 } 1697 }
1698 if ( line.left( 8 ) == "ERROR_FI" ) { 1698 if ( line.left( 8 ) == "ERROR_FI" ) {
1699 mRetVal = errorFI; 1699 mRetVal = errorFI;
1700 deleteSocket(); 1700 deleteSocket();
1701 return ; 1701 return ;
1702 } 1702 }
1703 if ( line.left( 8 ) == "ERROR_ED" ) { 1703 if ( line.left( 8 ) == "ERROR_ED" ) {
1704 mRetVal = errorED; 1704 mRetVal = errorED;
1705 deleteSocket(); 1705 deleteSocket();
1706 return ; 1706 return ;
1707 } 1707 }
1708 mRetVal = errorUN; 1708 mRetVal = errorUN;
1709 deleteSocket(); 1709 deleteSocket();
1710 return ; 1710 return ;
1711 } 1711 }
1712 } 1712 }
1713 mFileString += line; 1713 mFileString += line;
1714 //qDebug("readline: %s ", line.latin1()); 1714 //qDebug("readline: %s ", line.latin1());
1715 } 1715 }
1716 if ( mTime.elapsed () < 3000 ) { 1716 if ( mTime.elapsed () < 3000 ) {
1717 // wait for more 1717 // wait for more
1718 //qDebug("waitformore "); 1718 //qDebug("waitformore ");
1719 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1719 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1720 return; 1720 return;
1721 } 1721 }
1722 mTimerSocket->stop(); 1722 mTimerSocket->stop();
1723 mConnectCount = -1; 1723 mConnectCount = -1;
1724 mConnectProgress.hide(); 1724 mConnectProgress.hide();
1725 QString fileName = mFileName; 1725 QString fileName = mFileName;
1726 QFile file ( fileName ); 1726 QFile file ( fileName );
1727 if (!file.open( IO_WriteOnly ) ) { 1727 if (!file.open( IO_WriteOnly ) ) {
1728 mFileString = ""; 1728 mFileString = "";
1729 mRetVal = errorR; 1729 mRetVal = errorR;
1730 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1730 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1731 deleteSocket(); 1731 deleteSocket();
1732 return ; 1732 return ;
1733 1733
1734 } 1734 }
1735 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1735 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1736 QTextStream ts ( &file ); 1736 QTextStream ts ( &file );
1737 ts.setEncoding( QTextStream::Latin1 ); 1737 ts.setEncoding( QTextStream::Latin1 );
1738 ts << mFileString; 1738 ts << mFileString;
1739 file.close(); 1739 file.close();
1740 mFileString = ""; 1740 mFileString = "";
1741 mRetVal = successR; 1741 mRetVal = successR;
1742 mSocket->close(); 1742 mSocket->close();
1743 // if state is not idle, deleteSocket(); is called via 1743 // if state is not idle, deleteSocket(); is called via
1744 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1744 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1745 if ( mSocket->state() == QSocket::Idle ) 1745 if ( mSocket->state() == QSocket::Idle )
1746 deleteSocket(); 1746 deleteSocket();
1747} 1747}
1748 1748
1749void KCommandSocket::deleteSocket() 1749void KCommandSocket::deleteSocket()
1750{ 1750{
1751 //qDebug("KCommandSocket::deleteSocket() "); 1751 //qDebug("KCommandSocket::deleteSocket() ");
1752 mConnectProgress.hide(); 1752 mConnectProgress.hide();
1753 1753
1754 if ( mConnectCount >= 0 ) { 1754 if ( mConnectCount >= 0 ) {
1755 mTimerSocket->stop(); 1755 mTimerSocket->stop();
1756 mRetVal = errorTO; 1756 mRetVal = errorTO;
1757 qDebug("KCS::Connection to remote host timed out"); 1757 qDebug("KCS::Connection to remote host timed out");
1758 if ( mSocket ) { 1758 if ( mSocket ) {
1759 mSocket->close(); 1759 mSocket->close();
1760 //if ( mSocket->state() == QSocket::Idle ) 1760 //if ( mSocket->state() == QSocket::Idle )
1761 // deleteSocket(); 1761 // deleteSocket();
1762 delete mSocket; 1762 delete mSocket;
1763 mSocket = 0; 1763 mSocket = 0;
1764 } 1764 }
1765 if ( mConnectCount == 0 ) 1765 if ( mConnectCount == 0 )
1766 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1766 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1767 else if ( tlw ) 1767 else if ( tlw )
1768 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1768 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1769 emit commandFinished( this, mRetVal ); 1769 emit commandFinished( this, mRetVal );
1770 return; 1770 return;
1771 } 1771 }
1772 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1772 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1773 if ( mSocket) 1773 if ( mSocket)
1774 delete mSocket; 1774 delete mSocket;
1775 mSocket = 0; 1775 mSocket = 0;
1776 qDebug("commandFinished "); 1776 //qDebug("commandFinished ");
1777 emit commandFinished( this, mRetVal ); 1777 emit commandFinished( this, mRetVal );
1778} 1778}