Logo Search packages:      
Sourcecode: kmess version File versions  Download package

bool MsnConnection::switchToTcpSocket (  )  [protected, inherited]

Switch back to the TCP connection.

This method checks what connection is being established, and if is an HTTP connection, will delete it and start using again the TCP method.

This is used after disconnecting from an HTTP session, to try again with TCP the next time.

Definition at line 976 of file msnconnection.cpp.

References MsnConnection::attachToSocketSignals(), MsnSocketBase::disconnectFromServer(), MsnSocketBase::getAcceptedPayloadCommands(), MsnSocketBase::getServerType(), and MsnSocketBase::setAcceptedPayloadCommands().

{
  // Check if we're already using TCP
  if( qobject_cast<MsnSocketTcp*>( socket_ ) )
  {
#ifdef KMESSDEBUG_CONNECTION_SOCKET
    kDebug() << "Cannot switch to TCP connection. Class is" << socket_->metaObject()->className();
#endif
    return false;
  }

#ifdef KMESSDEBUG_CONNECTION_SOCKET
  kDebug() << "Attempting to switch back to TCP connection.";
#endif

  // Save the socket details to use the same ones for the new socket
  MsnSocketBase::ServerType serverType = socket_->getServerType();
  QStringList acceptedPayloadCommands = socket_->getAcceptedPayloadCommands();

  // Close and disable the old server
  socket_->blockSignals( true );
  disconnect( socket_, 0 );
  socket_->disconnectFromServer();
  socket_->deleteLater();

  // Replace it with the new one
  socket_ = new MsnSocketTcp( serverType );
  socket_->setAcceptedPayloadCommands( acceptedPayloadCommands );

  // Set the internal socket switch
  useHttpSocket_ = false;

  // Attach its signals to this class
  attachToSocketSignals();

  return true;
}


Generated by  Doxygen 1.6.0   Back to index