CVS commit by hermier: Changed the ping pong (PNG/QNG) handling. Now the code should follow the QNG timeout specs. In the previous code the ping was sent with an arbitrary static value, which could make you disconnect under some conditions. M +12 -14 msnnotifysocket.cpp 1.166 M +5 -11 msnnotifysocket.h 1.45 M +0 -1 msnsocket.cpp 1.104 M +0 -6 msnsocket.h 1.30 --- kdenetwork/kopete/protocols/msn/msnnotifysocket.cpp #1.165:1.166 @@ -61,6 +61,4 @@ MSNNotifySocket::MSNNotifySocket( MSNAcc m_keepaliveTimer = new QTimer( this, "m_keepaliveTimer" ); QObject::connect( m_keepaliveTimer, SIGNAL( timeout() ), SLOT( slotSendKeepAlive() ) ); - - QObject::connect( this, SIGNAL( commandSent() ), SLOT( slotResetKeepAlive() ) ); } @@ -306,4 +304,7 @@ void MSNNotifySocket::parseCommand( cons QString publicName = unescape( data.section( ' ', 2, 2 ) ); emit publicNameChanged( publicName ); + + // We are connected start to ping + slotSendKeepAlive(); } } @@ -531,4 +532,8 @@ void MSNNotifySocket::parseCommand( cons //this is a reply from a ping m_ping=false; + + // id is the timeout in fact, and we remove 5% of it + m_keepaliveTimer->start( id * 950, true ); + kdDebug( 14140 ) << k_funcinfo << "timerTimeout=" << id << "sec"<< endl; } else if( cmd == "URL" ) @@ -902,11 +907,4 @@ void MSNNotifySocket::slotSendKeepAlive( } -void MSNNotifySocket::slotResetKeepAlive() -{ - // Fire the timer every 90 seconds. QTimer will reset a running timer - // on a subsequent call if there has been activity again. - m_keepaliveTimer->start( 90000 ); -} - Kopete::OnlineStatus MSNNotifySocket::convertOnlineStatus( const QString &status ) { --- kdenetwork/kopete/protocols/msn/msnnotifysocket.h #1.44:1.45 @@ -132,10 +132,4 @@ private slots: void slotSendKeepAlive(); - /** - * Reset the keepalive time after the socket has sent a command. - */ - void slotResetKeepAlive(); - - void slotAuthJobDataReceived ( KIO::Job *, const QByteArray &data); --- kdenetwork/kopete/protocols/msn/msnsocket.cpp #1.103:1.104 @@ -468,5 +468,4 @@ void MSNSocket::slotReadyWrite() m_socket->writeBlock( *it, ( *it ).length() ); m_sendQueue.remove( it ); - emit commandSent(); // If the queue is empty again stop waiting for readyWrite signals --- kdenetwork/kopete/protocols/msn/msnsocket.h #1.29:1.30 @@ -125,10 +125,4 @@ signals: void socketClosed(); - /** - * The socket just sent a command from the queue. This signal is used in - * the notify socket to reset the keepalive timer. - */ - void commandSent(); - protected: /**