Logo Search packages:      
Sourcecode: kmess version File versions

void P2PApplicationBase::gotErrorAck ( const P2PMessage message  )  [private]

Called when a P2P message was received with the error-flag set.

This method aborts the application by calling contactAborted().

Parameters:
message The received error message.

Definition at line 550 of file p2papplicationbase.cpp.

References abortDataSending(), Application::contactAborted(), endApplicationLater(), P2PMessage::getAckDataSize(), P2PMessage::getAckSessionID(), P2PMessage::getAckUniqueID(), Application::getContactHandle(), P2PMessage::getDataSize(), P2PMessage::getFlags(), P2PMessage::getTotalSize(), Application::isClosing(), P2PMessage::isError(), P2PMessage::isNegativeAck(), P2P_TYPE_NEGOTIATION, P2P_WAIT_FOR_DATA_ACK, P2P_WAIT_FOR_SLP_BYE, and setWaitingState().

Referenced by gotMessage().

{
#ifdef KMESSTEST
  KMESS_ASSERT( message.getDataSize()     == 0 );

  if( message.isNegativeAck() )
  {
    KMESS_ASSERT( message.getTotalSize()  == 0 );
  }
  else if( message.isError() )
  {
    KMESS_ASSERT( message.getTotalSize()  != 0 );
  }

  KMESS_ASSERT( message.getAckSessionID() != 0 );
  KMESS_ASSERT( message.getAckUniqueID()  == 0 );
  KMESS_ASSERT( message.getAckDataSize()  == 0 );
#endif

  // When the contact aborted, it could send some 0x08 messages back for the
  // next fragments which were already sent (e.g. already in the DC at that time).
  // Ignore these error messages.
  if( isClosing() )
  {
#ifdef KMESSDEBUG_P2PAPPLICATION_GENERAL
    kDebug() << "Got an P2P error-response while closing "
                 "(flag=0x"  << QString::number( message.getFlags(), 16 ) <<
                 ", ignoring message).";
#endif

    // Make sure the timer resumes.
    endApplicationLater();
    return;
  }

  if( message.isNegativeAck() )
  {
    // Received when the transfer failed, e.g. write errors at the direct connection.
    kWarning() << "Got an unexpected P2P error-response "
                  "(flag=nak" <<
                  " byte="    << message.getDataSize() <<
                  " state="   << waitingState_ <<
                  " contact=" << getContactHandle() <<
                  " session=" << getSessionID() <<
                  " class="   << metaObject()->className() <<
                  " action=continue).";

    // TODO: resume transfer at the indicated byte position.
    abortDataSending();

#ifdef KMESSDEBUG_P2PAPPLICATION_GENERAL
    kDebug() << "Waiting for contact to send a BYE message.";
#endif

    // Wait for BYE at the moment.
    setWaitingState( P2P_WAIT_FOR_SLP_BYE, P2PAPPLICATION_TIMEOUT_SLP );
  }
  else
  {
    // Error in our headers?
    kWarning() << "Got an unexpected P2P error-response "
                  "(flag=0x"  << QString::number( message.getFlags(), 16 ) <<
                  " state="   << waitingState_ <<
                  " contact=" << getContactHandle() <<
                  " session=" << getSessionID() <<
                  " class="   << metaObject()->className() <<
                  " action=contactaborted).";


    if( dataType_ == P2P_TYPE_NEGOTIATION && ! P2P_WAIT_FOR_DATA_ACK )
    {
      // We likely made an error in the invitation/bye reponse
      contactAborted( i18n("The contact rejected the invitation. An internal error occured.") );
    }
    else
    {
      // TODO: make this error custom.
      // We were sending or receiving a file/picture
      // Can also happen if the contact can't handle our data for a different reason.
      contactAborted( i18n("The transfer failed.") );
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index