soc.2009.transport: 41b99efa: Fixed jabber:iq:gateway support.
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Tue Jun 2 04:30:55 EDT 2009
-----------------------------------------------------------------
Revision: 41b99efae03aa9e02d9e75fb49a23c465a01caa0
Ancestor: cc3320d794aa56e9e7566ad1e934db424ca2a003
Author: hanzz at soc.pidgin.im
Date: 2009-06-02T08:27:32
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/41b99efae03aa9e02d9e75fb49a23c465a01caa0
Modified files:
CMakeLists.txt gatewayhandler.cpp gatewayhandler.h main.cpp
ChangeLog:
Fixed jabber:iq:gateway support.
-------------- next part --------------
============================================================
--- CMakeLists.txt da8aee69f24f90fd659c2d7c21590738dc6731c4
+++ CMakeLists.txt b7242181433456cef8cd61b9e0546f2f59b058fe
@@ -51,11 +51,11 @@
endif(GLIB2_FOUND)
-if(CMAKE_BUILD_TYPE MATCHES Debug)
+#if(CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS(-ggdb)
ADD_DEFINITIONS(-DDEBUG)
ADD_DEFINITIONS(-Wall)
-endif(CMAKE_BUILD_TYPE MATCHES Debug)
+#endif(CMAKE_BUILD_TYPE MATCHES Debug)
#CONFIGURE_FILE(config.h.in config.h)
============================================================
--- gatewayhandler.cpp 81f8dd1b711d03d39ee5cc5c2a14ffdf6430f2e4
+++ gatewayhandler.cpp d63322f0bfb56e04958638dfb2345346b35558dd
@@ -23,8 +23,36 @@
#include "main.h"
#include "sql.h"
+GatewayExtension::GatewayExtension() : StanzaExtension( ExtGateway )
+{
+ m_tag = NULL;
+}
+
+GatewayExtension::GatewayExtension(const Tag *tag) : StanzaExtension( ExtGateway )
+{
+ m_tag = tag->clone();
+}
+
+GatewayExtension::~GatewayExtension()
+{
+ Log().Get("GatewayExtension") << "deleting GatewayExtension()";
+ delete m_tag;
+}
+
+const std::string& GatewayExtension::filterString() const
+{
+ static const std::string filter = "iq/query[@xmlns='jabber:iq:gateway']";
+ return filter;
+}
+
+Tag* GatewayExtension::tag() const
+{
+ return m_tag->clone();
+}
+
GlooxGatewayHandler::GlooxGatewayHandler(GlooxMessageHandler *parent) : IqHandler(){
p=parent;
+ p->j->registerStanzaExtension( new GatewayExtension() );
}
GlooxGatewayHandler::~GlooxGatewayHandler(){
@@ -35,7 +63,7 @@ std::string GlooxGatewayHandler::replace
// Find the first string to replace
int index = str.find(string_to_replace);
// while there is one
- while(index != std::string::npos)
+ while(index != (int) std::string::npos)
{
// Replace it
str.replace(index, strlen(string_to_replace), new_string);
@@ -60,15 +88,18 @@ bool GlooxGatewayHandler::handleIq (cons
IQ _s(IQ::Result, stanza.from(), stanza.id());
_s.setFrom(p->jid());
Tag *s = _s.tag();
- s->setXmlns("jabber:iq:gateway");
+ Tag *query = new Tag("query");
+ query->setXmlns("jabber:iq:gateway");
- s->findChild("query")->addChild(new Tag("desc","Please enter the ICQ Number of the person you would like to contact."));
- s->findChild("query")->addChild(new Tag("prompt","Contact ID"));
+ query->addChild(new Tag("desc","Please enter the ICQ Number of the person you would like to contact."));
+ query->addChild(new Tag("prompt","Contact ID"));
+ s->addChild(query);
p->j->send( s );
return true;
}
else if(stanza.subtype() == IQ::Set){
+ Log().Get("tag") << stanza.tag()->xml();
Tag *query = stanza.tag()->findChild("query");
if (query==NULL)
return false;
@@ -84,10 +115,14 @@ bool GlooxGatewayHandler::handleIq (cons
IQ _s(IQ::Result, stanza.from(), stanza.id());
_s.setFrom(p->jid());
Tag *s = _s.tag();
- s->setXmlns("jabber:iq:gateway");
- s->findChild("query")->addChild(new Tag("jid",uin+"@"+p->jid()));
- s->findChild("query")->addChild(new Tag("prompt",uin+"@"+p->jid()));
+ query = new Tag("query");
+ query->setXmlns("jabber:iq:gateway");
+ query->addChild(new Tag("jid",uin+"@"+p->jid()));
+ query->addChild(new Tag("prompt",uin+"@"+p->jid()));
+
+ s->addChild(query);
+
p->j->send( s );
return true;
}
============================================================
--- gatewayhandler.h 4edd3a90613e26fda1e4714cce970812b49c8bf8
+++ gatewayhandler.h a5d60b5633b1f00cb38e46ff2012d773a775db7b
@@ -28,7 +28,45 @@ using namespace gloox;
using namespace gloox;
+class GatewayExtension : public StanzaExtension
+{
+public:
+ /**
+ * Constructs a new object from the given Tag.
+ */
+ GatewayExtension();
+ GatewayExtension(const Tag *tag);
+
+ /**
+ * Virtual Destructor.
+ */
+ virtual ~GatewayExtension();
+
+ // reimplemented from StanzaExtension
+ virtual const std::string& filterString() const;
+
+ // reimplemented from StanzaExtension
+ virtual StanzaExtension* newInstance( const Tag* tag ) const
+ {
+ return new GatewayExtension(tag);
+ }
+
+ // reimplemented from StanzaExtension
+ virtual Tag* tag() const;
+
+ // reimplemented from StanzaExtension
+ virtual StanzaExtension* clone() const
+ {
+ return new GatewayExtension(m_tag);
+ }
+
+private:
+ Tag *m_tag;
+
+};
+
+
class GlooxGatewayHandler : public IqHandler
{
============================================================
--- main.cpp 124729b0954716d45a29adf3ee178ef460e2b097
+++ main.cpp a522899b936a6838113941f0d5d24d74bc12c9a7
@@ -500,7 +500,7 @@ GlooxMessageHandler::GlooxMessageHandler
j->registerMessageHandler( this );
j->registerConnectionListener(this);
gatewayHandler = new GlooxGatewayHandler(this);
- j->registerIqHandler(gatewayHandler,"jabber:iq:gateway");
+ j->registerIqHandler(gatewayHandler,ExtGateway);
m_reg = new GlooxRegisterHandler(this);
j->registerIqHandler(m_reg,ExtRegistration);
m_xping = new GlooxXPingHandler(this);
More information about the Commits
mailing list