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

void MsnObjectTransferP2P::contactStarted1_ContactInvitesUser ( const MimeMessage message  )  [private, virtual]

Step one of a contact-started chat: the contact invites the user

On error, send an 500 Internal Error back. The error will be acked and the application will terminate.

Parameters:
message The invitation message

Reimplemented from P2PApplication.

Definition at line 85 of file msnobjecttransferp2p.cpp.

References Application::CANCEL_FAILED, contactStarted1_gotDisplayPictureRequest(), contactStarted1_gotEmoticonRequest(), Application::getContactHandle(), MsnObject::getType(), MimeMessage::getValue(), and P2PApplication::sendCancelMessage().

{
#ifdef KMESSDEBUG_MSNOBJECTTRANSFER_P2P
  kDebug();
#endif

  // Extract the fields from the message
  unsigned long int appID   = message.getValue("AppID").toUInt();
  QString           context( message.getValue("Context") );

  // Extract the MSNObject from the context field, to determine which picture/emoticon the contact wants

  // Just to be on the safe side, check the buffer size before we start decoding
  if( context.length() <= 24 )
  {
    kWarning() << "MSNObject transfer context field has bad formatting, "
                  "ignoring invite (context=" << context << ", contact=" << getContactHandle() << ").";
    sendCancelMessage( CANCEL_FAILED );
    return;
  }

  // Decode the MSN Object contained in the Context field to a string
  // Decode that string to an MSN Object
  QByteArray decodedContext = QByteArray::fromBase64( context.toLatin1() );
  QString contextString( decodedContext );
  msnObject_ = MsnObject( contextString );

#ifdef KMESSDEBUG_MSNOBJECTTRANSFER_P2P
  kDebug() << "Got context \"" << contextString << "\".";
// Got context <msnobj Creator="contact@hotmail.com" Size="9442" Type="3" Location="KMess.tmp" Friendly="AA==" SHA1D="FyY3n97RHXDgQujca4FVMv4VIF0=" SHA1C="qsT1Tqmtt7Z0LucXOq1pd9p7cIE="/>
#endif


  switch( msnObject_.getType() )
  {
    case MsnObject::DISPLAYPIC:

      // Test protocol compatibility.
      if( appID != 1 && appID != 12 )    // Display pictures -  AppID 12 is used as of MSN Messenger 7.5
      {
        kDebug() << "Received a request for a display picture, but unexpected appID was set "
                    "(appid=" << appID <<
                    " type=" << msnObject_.getType() <<
                    " contact=" << getContactHandle() << " action=continue).";
      }

      // Continue at separate function
      contactStarted1_gotDisplayPictureRequest();
      return;

    case MsnObject::EMOTICON:

      // Test protocol compatibility.
      if( appID != 1      // HACK: added for compatibility with Messenger for the Mac 6.0.3 and aMsn 0.97rc1
      &&  appID != 11 )   // Custom emoticons
      {
        kDebug() << "Received a request for an emoticon, but unexpected appID was set "
                    "(appid=" << appID <<
                    " type=" << msnObject_.getType() <<
                    " contact=" << getContactHandle() << " action=continue).";
      }

      // Continue at separate function
      contactStarted1_gotEmoticonRequest();
      return;


    // Avoid gcc warnings about missing values.
    // But don't use "default" so the check remains intact.
    case MsnObject::BACKGROUND:
    case MsnObject::DELUXE_DISPLAYPIC:
      break;
    case MsnObject::WINK:
      contactStarted1_gotWinkRequest();
      return;
    default:
      break;
  }

  // Unknown application type
  kWarning() << "Received an invitation for an unexpected object type "
                "(appid=" << appID <<
                " type=" << msnObject_.getType() <<
                " contact=" << getContactHandle() << ").";

  // Abort the contact.
  sendCancelMessage( CANCEL_FAILED );
}


Generated by  Doxygen 1.6.0   Back to index