Logo Search packages:      
Sourcecode: kmess version File versions

webapplicationp2p.cpp

/***************************************************************************
                          webapplicationp2p.cpp -  description
                             -------------------
    begin                : Sun Aug 7 2005
    copyright            : (C) 2005 by Diederik van der Boor
    email                : vdboor --at-- codingdomain.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "webapplicationp2p.h"

#include "../../kmessdebug.h"
#include "../mimemessage.h"

#include <KLocale>



/**
 * Constructor
 *
 * @param  applicationList  The shared sources for the contact.
 */
00032 WebApplicationP2P::WebApplicationP2P(ApplicationList *applicationList)
: P2PApplication(applicationList)
{
}


/* *
 * Constructor
 *
 * @param  applicationList  The shared sources for the contact.
 * @param  applicationId    The ID of the web application to start.
 */
/*
WebApplicationP2P::WebApplicationP2P(const QString &contactHandle, int applicationId)
: P2PApplication(contactHandle)
{
}
*/


/**
 * Destructor
 */
00055 WebApplicationP2P::~WebApplicationP2P()
{
}



/**
 * Step one of a contact-started chat: the contact invites the user
 *
 * @param  message  The invitation message
 */
00066 void WebApplicationP2P::contactStarted1_ContactInvitesUser(const MimeMessage &message)
{
#ifdef KMESSDEBUG_WEBAPPLICATION_P2P
  kDebug() << "contactStarted1_ContactInvitesUser";
#endif


  QString  appID  ( message.getValue("AppID") );
  QString  context( message.getValue("Context") );

#ifdef KMESSTEST
  KMESS_ASSERT( appID.length() == 8 );
#endif

  // Split the appID
//  int languageCode = appID.mid(0, 4).toInt();
//  int realAppID    = appID.mid(4, 4).toInt();

  // Parse the context
  // Contents is something like '10331021;1;Tic Tac Toe'
  QByteArray decodedContext = QByteArray::fromBase64( context.toLatin1() );
  QString    contextString  ( QString::fromUtf16( reinterpret_cast<const ushort*>( decodedContext.data() ), decodedContext.size() / 2 ) );

  // Get the fields
  QString unknown( contextString.section(';', 1, 1) );
  QString appName( contextString.section(';', 2, 2) );

#ifdef KMESSTEST
  // Not sure why, the AppID is included with the context again
  KMESS_ASSERT( contextString.section(';', 0, 0) == appID );
#endif

  // KMess does not support the webapplication invitations yet,
  // this class only parses the context so we can produce a proper error message
  // Warn the user we received an unknown invitation
  showSystemMessage( i18n( "The contact is inviting you for '%1', but this is not implemented yet.",
                           appName ),
                     ChatMessage::CONTENT_SYSTEM_NOTICE, true );

  // Tell the contact we don't support this.
  sendCancelMessage(CANCEL_NOT_INSTALLED);

//  // Everything seams OK, accept this message:
//  contactStarted2_UserAccepts();
}



/**
 * Return the application's GUID.
 */
00117 QString WebApplicationP2P::getAppId()
{
  return "{6A13AF9C-5308-4F35-923A-67E8DDA40C2F}";
}

#include "webapplicationp2p.moc"

Generated by  Doxygen 1.6.0   Back to index