From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../jabber/jingle/jinglewatchsessiontask.cpp | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 kopete/protocols/jabber/jingle/jinglewatchsessiontask.cpp (limited to 'kopete/protocols/jabber/jingle/jinglewatchsessiontask.cpp') diff --git a/kopete/protocols/jabber/jingle/jinglewatchsessiontask.cpp b/kopete/protocols/jabber/jingle/jinglewatchsessiontask.cpp new file mode 100644 index 00000000..fc7de053 --- /dev/null +++ b/kopete/protocols/jabber/jingle/jinglewatchsessiontask.cpp @@ -0,0 +1,75 @@ +/* + jingleswatchsessiontask.cpp - Watch for incoming Jingle sessions. + + Copyright (c) 2006 by Michaƫl Larouche + + Kopete (c) 2001-2006 by the Kopete developers + + ************************************************************************* + * * + * 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 "jinglewatchsessiontask.h" + +#include + +#include "jabberprotocol.h" + +#define JINGLE_NS "http://www.google.com/session" + +JingleWatchSessionTask::JingleWatchSessionTask(XMPP::Task *parent) + : Task(parent) +{} + +JingleWatchSessionTask::~JingleWatchSessionTask() +{} + +//NOTE: This task watch for pre-JEP session. +bool JingleWatchSessionTask::take(const QDomElement &element) +{ + if(element.tagName() != "iq") + return false; + + QString sessionType, initiator; + + QDomElement first = element.firstChild().toElement(); + if( !first.isNull() && first.attribute("xmlns") == JINGLE_NS && first.tagName() == "session" ) + { + kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Checking for incoming sesssion." << endl; + initiator = first.attribute("initiator"); + + // Only proceed initiate type Jingle XMPP call. + if( first.attribute("type") != QString::fromUtf8("initiate") ) + return false; + + int nodeIndex; + + QDomNodeList nodeList = first.childNodes(); + // Do not check first child + for(nodeIndex = 0; nodeIndex < nodeList.length(); nodeIndex++) + { + QDomElement nodeElement = nodeList.item(nodeIndex).toElement(); + if(nodeElement.tagName() == "description") + { + sessionType = nodeElement.attribute("xmlns"); + } + } + + if( !initiator.isEmpty() && !sessionType.isEmpty() ) + { + kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Emmiting incoming sesssion." << endl; + emit watchSession(sessionType, initiator); + return true; + } + } + + return false; +} + +#include "jinglewatchsessiontask.moc" \ No newline at end of file -- cgit v1.2.1