# # Machekku Make Psi Pingable # # Version: 0.1 # Date: 2007-01-20 # # pongserver.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ # pongserver.h | 36 ++++++++++++++++++++++++++++++++++++ # psiaccount.cpp | 4 ++++ # src.pri | 2 ++ # diff -rN -u old-psi/src/pongserver.cpp new-psi/src/pongserver.cpp --- old-psi/src/pongserver.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new-psi/src/pongserver.cpp 2007-01-20 13:27:30.765625000 +0100 @@ -0,0 +1,55 @@ +/* + * pongserver.cpp - XMPP Ping server + * Copyright (C) 2007 Maciej Niedzielski + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "pongserver.h" +#include "xmpp_xmlcommon.h" + +using namespace XMPP; + + +/** + * \class PongServer + * \brief Answers XMPP Pings + */ + +PongServer::PongServer(Task *parent) +:Task(parent) +{ +} + +PongServer::~PongServer() +{ +} + +bool PongServer::take(const QDomElement &e) +{ + if (e.tagName() != "iq" || e.attribute("type") != "get") + return false; + + bool found = false; + QDomElement ping = findSubTag(e, "ping", &found); + if (found && ping.attribute("xmlns") == "urn:xmpp:ping") { + QDomElement iq = createIQ(doc(), "result", e.attribute("from"), e.attribute("id")); + send(iq); + return true; + } + return false; +} + diff -rN -u old-psi/src/pongserver.h new-psi/src/pongserver.h --- old-psi/src/pongserver.h 1970-01-01 01:00:00.000000000 +0100 +++ new-psi/src/pongserver.h 2007-01-20 13:27:30.765625000 +0100 @@ -0,0 +1,36 @@ +/* + * pongserver.h - XMPP Ping server + * Copyright (C) 2007 Maciej Niedzielski + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef PONGSERVER_H +#define PONGSERVER_H + +#include "xmpp_task.h" + +class PongServer : public XMPP::Task +{ + Q_OBJECT +public: + PongServer(Task *); + ~PongServer(); + bool take(const QDomElement &); +}; + +#endif + diff -rN -u old-psi/src/psiaccount.cpp new-psi/src/psiaccount.cpp --- old-psi/src/psiaccount.cpp 2007-01-20 13:26:56.687500000 +0100 +++ new-psi/src/psiaccount.cpp 2007-01-20 13:27:39.515625000 +0100 @@ -47,6 +47,7 @@ #include "im.h" #include "xmpp_tasks.h" #include "xmpp_xmlcommon.h" +#include "pongserver.h" #include "s5b.h" #include "filetransfer.h" #include "pgpkeydlg.h" @@ -535,6 +536,9 @@ d->serverInfoManager = new ServerInfoManager(d->client); connect(d->serverInfoManager,SIGNAL(featuresChanged()),SLOT(serverFeaturesChanged())); + // XMPP Ping + new PongServer(d->client->rootTask()); + // Initialize PubSub stuff d->pepManager = new PEPManager(d->client, d->serverInfoManager); connect(d->pepManager,SIGNAL(itemPublished(const Jid&, const QString&, const PubSubItem&)),SLOT(itemPublished(const Jid&, const QString&, const PubSubItem&))); diff -rN -u old-psi/src/src.pri new-psi/src/src.pri --- old-psi/src/src.pri 2007-01-20 13:26:58.562500000 +0100 +++ new-psi/src/src.pri 2007-01-20 13:27:40.765625000 +0100 @@ -189,6 +189,7 @@ $$PWD/ahcformdlg.h \ $$PWD/ahcexecutetask.h \ $$PWD/ahcservermanager.h \ + $$PWD/pongserver.h \ $$PWD/psioptions.h \ $$PWD/voicecaller.h \ $$PWD/voicecalldlg.h \ @@ -299,6 +300,7 @@ $$PWD/ahcformdlg.cpp \ $$PWD/ahcexecutetask.cpp \ $$PWD/ahcservermanager.cpp \ + $$PWD/pongserver.cpp \ $$PWD/psioptions.cpp \ $$PWD/voicecalldlg.cpp \ $$PWD/resourcemenu.cpp \