soc.2009.transport: cc3320d7: Fixed registration handler and added sup...
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Tue Jun 2 04:30:57 EDT 2009
-----------------------------------------------------------------
Revision: cc3320d794aa56e9e7566ad1e934db424ca2a003
Ancestor: ee229ad4b2b3ecc0538b176a754e0deefb256131
Author: hanzz at soc.pidgin.im
Date: 2009-06-02T07:42:46
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/cc3320d794aa56e9e7566ad1e934db424ca2a003
Added files:
protocols/gg.cpp protocols/gg.h
Modified files:
CMakeLists.txt discoinfohandler.cpp main.cpp
registerhandler.cpp xpinghandler.cpp
ChangeLog:
Fixed registration handler and added support for GG network
-------------- next part --------------
============================================================
--- protocols/gg.cpp 327a7f6c2ef739b75f166ca6d7f5831fc8e23e32
+++ protocols/gg.cpp 327a7f6c2ef739b75f166ca6d7f5831fc8e23e32
@@ -0,0 +1,82 @@
+/**
+ * XMPP - libpurple transport
+ *
+ * Copyright (C) 2009, Jan Kaluza <hanzz at soc.pidgin.im>
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include "gg.h"
+#include "../main.h"
+
+GGProtocol::GGProtocol(GlooxMessageHandler *main){
+ m_main = main;
+ m_transportFeatures.push_back("jabber:iq:register");
+ m_transportFeatures.push_back("http://jabber.org/protocol/disco#info");
+ m_transportFeatures.push_back("http://jabber.org/protocol/caps");
+ m_transportFeatures.push_back("http://jabber.org/protocol/chatstates");
+// m_transportFeatures.push_back("http://jabber.org/protocol/activity+notify");
+ m_transportFeatures.push_back("http://jabber.org/protocol/commands");
+
+ m_buddyFeatures.push_back("http://jabber.org/protocol/disco#info");
+ m_buddyFeatures.push_back("http://jabber.org/protocol/caps");
+ m_buddyFeatures.push_back("http://jabber.org/protocol/chatstates");
+ m_buddyFeatures.push_back("http://jabber.org/protocol/commands");
+
+// m_buddyFeatures.push_back("http://jabber.org/protocol/si/profile/file-transfer");
+// m_buddyFeatures.push_back("http://jabber.org/protocol/bytestreams");
+// m_buddyFeatures.push_back("http://jabber.org/protocol/si");
+}
+
+GGProtocol::~GGProtocol() {}
+
+std::string GGProtocol::replace(std::string &str, const char *string_to_replace, const char *new_string)
+{
+ // Find the first string to replace
+ int index = str.find(string_to_replace);
+ // while there is one
+ while(index != std::string::npos)
+ {
+ // Replace it
+ str.replace(index, strlen(string_to_replace), new_string);
+ // Find the next one
+ index = str.find(string_to_replace, index + strlen(new_string));
+ }
+ return str;
+}
+
+std::string GGProtocol::prepareUserName(std::string &str){
+ str = replace(str," ","");
+ return str;
+}
+
+bool GGProtocol::isValidUsername(std::string &str){
+ // TODO: check valid email address
+ return true;
+}
+
+std::list<std::string> GGProtocol::transportFeatures(){
+ return m_transportFeatures;
+}
+
+std::list<std::string> GGProtocol::buddyFeatures(){
+ return m_buddyFeatures;
+}
+
+std::string GGProtocol::text(const std::string &key) {
+ if (key == "instructions")
+ return "Enter your GG number and password:";
+ return "not defined";
+}
============================================================
--- protocols/gg.h e56ab9d7aeafcccd89411a28358120a9bb80ffc3
+++ protocols/gg.h e56ab9d7aeafcccd89411a28358120a9bb80ffc3
@@ -0,0 +1,51 @@
+/**
+ * XMPP - libpurple transport
+ *
+ * Copyright (C) 2009, Jan Kaluza <hanzz at soc.pidgin.im>
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef _HI_GG_PROTOCOL_H
+#define _HI_GG_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+
+class GGProtocol : AbstractProtocol
+{
+ public:
+ GGProtocol(GlooxMessageHandler *main);
+ ~GGProtocol();
+ std::string gatewayIdentity() { return "gg"; }
+ std::string protocol() { return "prpl-gg"; }
+ bool isValidUsername(std::string &username);
+ std::string prepareUserName(std::string &username);
+ std::list<std::string> transportFeatures();
+ std::list<std::string> buddyFeatures();
+ std::string text(const std::string &key);
+
+ std::string replace(std::string &str, const char *string_to_replace, const char *new_string);
+
+ private:
+ GlooxMessageHandler *m_main;
+ std::list<std::string> m_transportFeatures;
+ std::list<std::string> m_buddyFeatures;
+
+};
+
+#endif
+
\ No newline at end of file
============================================================
--- CMakeLists.txt 3c853a524803637ff27b19c0a7ba8602503f7a8f
+++ CMakeLists.txt da8aee69f24f90fd659c2d7c21590738dc6731c4
@@ -82,6 +82,7 @@
adhocrepeater.cpp
protocols/icq.cpp
protocols/facebook.cpp
+ protocols/gg.cpp
)
set(hiicq_MOC_HDRS
@@ -109,6 +110,7 @@
protocols/abstractprotocol.h
protocols/icq.h
protocols/facebook.h
+ protocols/gg.h
)
add_executable(hiicq ${hiicq_SRCS} ${lrelease_outputs})
============================================================
--- discoinfohandler.cpp f3a540cb046bb1b41b36a14395f22031ab6409df
+++ discoinfohandler.cpp bf62dc3c4a4bbc54606c6478261adaf6d918dd9b
@@ -58,7 +58,7 @@ bool GlooxDiscoInfoHandler::handleIq (co
</query>
</iq>*/
-// std::cout << "DISCO DISCO DISCO " << stanza.xml() << "\n";
+ std::cout << "DISCO DISCO DISCO INFO\n";
if(stanza.subtype() == IQ::Get && stanza.to().username()!="") {
Tag *query = stanza.tag()->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
if (query!=NULL){
============================================================
--- main.cpp c7de265b1082b2bf6c8d896d2267e4a082ef21c4
+++ main.cpp 124729b0954716d45a29adf3ee178ef460e2b097
@@ -29,6 +29,7 @@
#include "protocols/abstractprotocol.h"
#include "protocols/icq.h"
#include "protocols/facebook.h"
+#include "protocols/gg.h"
#include <gloox/tlsbase.h>
#include <gloox/compressionbase.h>
@@ -501,7 +502,7 @@ GlooxMessageHandler::GlooxMessageHandler
gatewayHandler = new GlooxGatewayHandler(this);
j->registerIqHandler(gatewayHandler,"jabber:iq:gateway");
m_reg = new GlooxRegisterHandler(this);
- j->registerIqHandler(m_reg,"jabber:iq:register");
+ j->registerIqHandler(m_reg,ExtRegistration);
m_xping = new GlooxXPingHandler(this);
j->registerIqHandler(m_xping,"urn:xmpp:ping");
m_stats = new GlooxStatsHandler(this);
@@ -530,7 +531,8 @@ void GlooxMessageHandler::loadProtocol()
m_protocol = (AbstractProtocol*) new ICQProtocol(this);
else if (configuration().protocol == "facebook")
m_protocol = (AbstractProtocol*) new FacebookProtocol(this);
-
+ else if (configuration().protocol == "gg")
+ m_protocol = (AbstractProtocol*) new GGProtocol(this);
// PurplePlugin *plugin = purple_find_prpl(m_protocol->protocol().c_str());
// if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
============================================================
--- registerhandler.cpp be8865233d27819de97faa1e9afee2ceeb38f954
+++ registerhandler.cpp 655a3c34fa3cf5c9e71a6c8548eba859f3b8e2b0
@@ -21,6 +21,7 @@
#include "registerhandler.h"
#include "main.h"
#include <gloox/clientbase.h>
+#include <gloox/registration.h>
#include <glib.h>
#include "sql.h"
#include "caps.h"
@@ -29,6 +30,7 @@ GlooxRegisterHandler::GlooxRegisterHandl
GlooxRegisterHandler::GlooxRegisterHandler(GlooxMessageHandler *parent) : IqHandler(){
p=parent;
+ p->j->registerStanzaExtension( new Registration::Query() );
}
GlooxRegisterHandler::~GlooxRegisterHandler(){
============================================================
--- xpinghandler.cpp afc5dd22fa9ae92b06c49bfb32ddf72b427f7ba5
+++ xpinghandler.cpp 2f4b9f321387d3e4476f9f4f28bdc49d1afe9bf8
@@ -28,6 +28,7 @@ bool GlooxXPingHandler::handleIq (const
}
bool GlooxXPingHandler::handleIq (const IQ &iq){
+ std::cout << "XPING\n";
IQ s(IQ::Result, iq.from(), iq.id());
std::string from;
from.append(p->jid());
More information about the Commits
mailing list