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

void P2PApplication::gotNegotiationFragment ( const P2PMessage p2pMessage  )  [private]

Got a message fragment with SessionID 0 All fragments are buffered and gotNegotiationMessage() is called when all parts are received

Parameters:
p2pMessage The received P2P message

Definition at line 836 of file p2papplication.cpp.

References P2PMessage::getData(), P2PMessage::getDataSize(), gotNegotiationMessage(), and P2PMessage::isLastFragment().

Referenced by gotMessage().

{
  if(! p2pMessage.isLastFragment())
  {
    // Not everything received yet, buffer it.
#ifdef KMESSDEBUG_P2PAPPLICATION_GENERAL
    kdDebug() << "P2PApplication: Got an SLP fragment, buffering it." << endl;
#endif

    if(buffer_ == 0)
    {
      buffer_ = new QBuffer();
      buffer_->open(IO_ReadWrite);
    }

    buffer_->writeBlock( p2pMessage.getData(), p2pMessage.getDataSize() );
  }
  else
  {
    // Read the message or buffer
    QString slpMessage;
    QByteArray bufferData;

    if(buffer_ != 0)
    {
#ifdef KMESSDEBUG_P2PAPPLICATION_GENERAL
      kdDebug() << "P2PApplication: Got the last SLP fragment." << endl;
#endif

      // Append the last MSNSLP fraqment and call the method.
      buffer_->writeBlock( p2pMessage.getData(), p2pMessage.getDataSize() );
      buffer_->reset();

      // Read the buffer
      bufferData = buffer_->readAll();
      slpMessage = QString::fromUtf8( bufferData.data(), bufferData.size() );

      delete buffer_;
      buffer_ = 0;
    }
    else
    {
      // Read the data directly from the message
      slpMessage = QString::fromUtf8( p2pMessage.getData(), p2pMessage.getDataSize() );
    }


    // Parse the negotiation message
    gotNegotiationMessage( slpMessage );
  }
}


Generated by  Doxygen 1.6.0   Back to index