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

void P2PApplication::sendSlpError ( const QString &  statusLine,
const uint  sessionID = 0,
const QString &  messageContentType = 0 
) [private]

Send an error response at SLP level. This can be done to decline a file tranfer or tell the other client it sent bad SLP data.

Parameters:
statusLine The status line, for example "200 OK", or "603 Decline"
sessionID ID of the current session (can be empty)
messageContentType Contact type of the message which is in error (can be empty)
The session ID can be 0 to indicate there was an error in the Content-Type. Setting the session ID and Content-Type to the values used in the INVITE message indicates you like to cancel that invitation.

Once this method returns the SessionID is set to 0 (which shouldn't be a problem since you use this method to end a session). This is because SLP messages are always sent without an SessionID.

Definition at line 1828 of file p2papplication.cpp.

References Account::getHandle(), and sendSlpMessage().

Referenced by gotMessage(), gotNegotiationMessage(), and sendCancelMessage().

{
#ifdef KMESSDEBUG_P2PAPPLICATION_GENERAL
  kdDebug() << "P2PApplication: Sending SLP error response: " << statusLine << endl;
#endif

#ifdef KMESSTEST
  // Test, as other invocations likely result in undefined client behavour
  // (
  ASSERT( ! shouldSendAck_ );
  ASSERT(   gotSlpMessage_ );
  ASSERT( waitingState_ == P2P_WAIT_DEFAULT );
#endif

  QString myHandle = CurrentAccount::instance()->getHandle();

  // Determine Content-Type and Content-Length fields
  QString content;
  QString contentType;
  uint    contentLength;

  if(sessionID == 0)
  {
    // Used to indicate a general error
    content       = QString::null;
    contentType   = "null";
    contentLength = 0;
  }
  else
  {
#ifdef KMESSTEST
    ASSERT(messageContentType != 0 && ! messageContentType.isEmpty());
#endif
    // Used to indicate an error in the Invite, or decline a session
    content       = "SessionID: " + QString::number(sessionID) + "\r\n\r\n\0";
    contentLength = content.length();
    contentType   = messageContentType;
  }

  // Create the message
  QString slpMessage;
  slpMessage = "MSNSLP/1.0 " + statusLine + "\r\n"
               "To: <msnmsgr:" + contactHandle_ + ">\r\n"
               "From: <msnmsgr:" + myHandle + ">\r\n"
               "Via: MSNSLP/1.0/TLP ;branch=" + branch_ + "\r\n"  // Indicates which INVITE was in error.
               "CSeq: 0\r\n"
               "Call-ID: " + callID_ + "\r\n"
               "Max-Forwards: 0\r\n"
               "Content-Type: " + contentType + "\r\n"
               "Content-Length: " + QString::number(contentLength) + "\r\n"
               + (contentLength > 0 ? "\r\n" : "")
               + content;

  // Send the message
  sendSlpMessage(slpMessage);

  // Wait for the message to be ACK-ed.
  waitingState_ = P2P_WAIT_FOR_SLP_ERR_ACK;
  waitingTimer_->start(30000, true); // 30 sec

#ifdef KMESSDEBUG_P2PAPPLICATION_GENERAL
  kdDebug() << "P2PApplication: Waiting for SLP ACK..." << endl;
#endif
}


Generated by  Doxygen 1.6.0   Back to index