soc.2009.transport: 5752f6e8: Added support for Yahoo, SIMPLE and QQ

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Thu Jul 2 04:55:22 EDT 2009


-----------------------------------------------------------------
Revision: 5752f6e8e419dc2b65c17b80464c18997aa89e5c
Ancestor: 046089ac1ca9ae646533c277f73fed5c370e02d3
Author: hanzz at soc.pidgin.im
Date: 2009-07-02T08:49:58
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/5752f6e8e419dc2b65c17b80464c18997aa89e5c

Added files:
        protocols/qq.cpp protocols/qq.h protocols/simple.cpp
        protocols/simple.h protocols/yahoo.cpp protocols/yahoo.h
Modified files:
        CMakeLists.txt main.cpp

ChangeLog: 

Added support for Yahoo, SIMPLE and QQ

-------------- next part --------------
============================================================
--- protocols/qq.cpp	6acf8f339083105e90ec136c0030674a7bd9bdc8
+++ protocols/qq.cpp	6acf8f339083105e90ec136c0030674a7bd9bdc8
@@ -0,0 +1,83 @@
+/**
+ * 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 "qq.h"
+#include "../main.h"
+
+QQProtocol::QQProtocol(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_transportFeatures.push_back("jabber:iq:search");
+	
+	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");
+}
+	
+QQProtocol::~QQProtocol() {}
+
+std::string QQProtocol::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 != (int) 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 QQProtocol::prepareUserName(std::string &str){
+	str = replace(str," ","");
+	return str;
+}
+
+bool QQProtocol::isValidUsername(std::string &str){
+	// TODO: check valid email address
+	return true;
+}
+
+std::list<std::string> QQProtocol::transportFeatures(){
+	return m_transportFeatures;
+}
+
+std::list<std::string> QQProtocol::buddyFeatures(){
+	return m_buddyFeatures;
+}
+
+std::string QQProtocol::text(const std::string &key) {
+	if (key == "instructions")
+		return "Enter your QQ username and password:";
+	return "not defined";
+}
============================================================
--- protocols/qq.h	ac5121ebeb5d86b00d8875580e68e321e876b988
+++ protocols/qq.h	ac5121ebeb5d86b00d8875580e68e321e876b988
@@ -0,0 +1,57 @@
+/**
+ * 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_QQ_PROTOCOL_H
+#define _HI_QQ_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+extern Localization localization;
+
+class QQProtocol : AbstractProtocol
+{
+	public:
+		QQProtocol(GlooxMessageHandler *main);
+		~QQProtocol();
+		std::string gatewayIdentity() { return "qq"; }
+		std::string protocol() { return "prpl-qq"; }
+		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);
+		Tag *getVCardTag(User *user, GList *vcardEntries) { return NULL; }
+		bool isMUC(User *user, const std::string &jid) { return false; }
+// 		std::string notifyUsername() { return "info"; }
+// 		std::string userSearchAction() { return "Search for buddies..."; }
+		
+		std::string replace(std::string &str, const char *string_to_replace, const char *new_string);
+// 		std::string userSearchColumn() { return "ID"; }
+	
+	private:
+		GlooxMessageHandler *m_main;
+		std::list<std::string> m_transportFeatures;
+		std::list<std::string> m_buddyFeatures;
+	
+};
+
+#endif	
+	
\ No newline at end of file
============================================================
--- protocols/simple.cpp	f106360253dd5b9d7038fc03c4163f7fbf3526a6
+++ protocols/simple.cpp	f106360253dd5b9d7038fc03c4163f7fbf3526a6
@@ -0,0 +1,83 @@
+/**
+ * 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 "simple.h"
+#include "../main.h"
+
+SimpleProtocol::SimpleProtocol(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_transportFeatures.push_back("jabber:iq:search");
+	
+	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");
+}
+	
+SimpleProtocol::~SimpleProtocol() {}
+
+std::string SimpleProtocol::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 != (int) 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 SimpleProtocol::prepareUserName(std::string &str){
+	str = replace(str," ","");
+	return str;
+}
+
+bool SimpleProtocol::isValidUsername(std::string &str){
+	// TODO: check valid email address
+	return true;
+}
+
+std::list<std::string> SimpleProtocol::transportFeatures(){
+	return m_transportFeatures;
+}
+
+std::list<std::string> SimpleProtocol::buddyFeatures(){
+	return m_buddyFeatures;
+}
+
+std::string SimpleProtocol::text(const std::string &key) {
+	if (key == "instructions")
+		return "Enter your Simple username and password:";
+	return "not defined";
+}
============================================================
--- protocols/simple.h	8ebc9ea935eddd9f3672f46030991f2893e24468
+++ protocols/simple.h	8ebc9ea935eddd9f3672f46030991f2893e24468
@@ -0,0 +1,57 @@
+/**
+ * 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_SIMPLE_PROTOCOL_H
+#define _HI_SIMPLE_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+extern Localization localization;
+
+class SimpleProtocol : AbstractProtocol
+{
+	public:
+		SimpleProtocol(GlooxMessageHandler *main);
+		~SimpleProtocol();
+		std::string gatewayIdentity() { return "simple"; }
+		std::string protocol() { return "prpl-simple"; }
+		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);
+		Tag *getVCardTag(User *user, GList *vcardEntries) { return NULL; }
+		bool isMUC(User *user, const std::string &jid) { return false; }
+// 		std::string notifyUsername() { return "info"; }
+// 		std::string userSearchAction() { return "Search for buddies..."; }
+		
+		std::string replace(std::string &str, const char *string_to_replace, const char *new_string);
+// 		std::string userSearchColumn() { return "ID"; }
+	
+	private:
+		GlooxMessageHandler *m_main;
+		std::list<std::string> m_transportFeatures;
+		std::list<std::string> m_buddyFeatures;
+	
+};
+
+#endif	
+	
\ No newline at end of file
============================================================
--- protocols/yahoo.cpp	47794489201de79ddfe57e03fa986c4e3d98def0
+++ protocols/yahoo.cpp	47794489201de79ddfe57e03fa986c4e3d98def0
@@ -0,0 +1,83 @@
+/**
+ * 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 "yahoo.h"
+#include "../main.h"
+
+YahooProtocol::YahooProtocol(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_transportFeatures.push_back("jabber:iq:search");
+	
+	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");
+}
+	
+YahooProtocol::~YahooProtocol() {}
+
+std::string YahooProtocol::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 != (int) 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 YahooProtocol::prepareUserName(std::string &str){
+	str = replace(str," ","");
+	return str;
+}
+
+bool YahooProtocol::isValidUsername(std::string &str){
+	// TODO: check valid email address
+	return true;
+}
+
+std::list<std::string> YahooProtocol::transportFeatures(){
+	return m_transportFeatures;
+}
+
+std::list<std::string> YahooProtocol::buddyFeatures(){
+	return m_buddyFeatures;
+}
+
+std::string YahooProtocol::text(const std::string &key) {
+	if (key == "instructions")
+		return "Enter your Simple username and password:";
+	return "not defined";
+}
============================================================
--- protocols/yahoo.h	36dc37fcbb4411cf0cd4e91024be13c4eef31339
+++ protocols/yahoo.h	36dc37fcbb4411cf0cd4e91024be13c4eef31339
@@ -0,0 +1,57 @@
+/**
+ * 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_YAHOO_PROTOCOL_H
+#define _HI_YAHOO_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+extern Localization localization;
+
+class YahooProtocol : AbstractProtocol
+{
+	public:
+		YahooProtocol(GlooxMessageHandler *main);
+		~YahooProtocol();
+		std::string gatewayIdentity() { return "yahoo"; }
+		std::string protocol() { return "prpl-yahoo"; }
+		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);
+		Tag *getVCardTag(User *user, GList *vcardEntries) { return NULL; }
+		bool isMUC(User *user, const std::string &jid) { return false; }
+// 		std::string notifyUsername() { return "info"; }
+// 		std::string userSearchAction() { return "Search for buddies..."; }
+		
+		std::string replace(std::string &str, const char *string_to_replace, const char *new_string);
+// 		std::string userSearchColumn() { return "ID"; }
+	
+	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	7e1f448ef45d8e5867cc64b0f6ecaf657e4d9f67
+++ CMakeLists.txt	d5396752ac1c03d8acb4a2a5e59a7c12c2f5e9d8
@@ -102,6 +102,9 @@
 	protocols/irc.cpp
 	protocols/xmpp.cpp
 	protocols/myspace.cpp
+	protocols/qq.cpp
+	protocols/simple.cpp
+	protocols/yahoo.cpp
 )
 
 set(hiicq_MOC_HDRS
@@ -143,6 +146,9 @@
 	protocols/irc.h
 	protocols/xmpp.h
 	protocols/myspace.h
+	protocols/qq.h
+	protocols/simple.h
+	protocols/yahoo.h
 )
 
 add_executable(hiicq ${hiicq_SRCS} ${lrelease_outputs})
============================================================
--- main.cpp	35f3043b0a89561e88f81bfdc8466c7bd617afd0
+++ main.cpp	8820215b8cab1366e06ed4633c2fdf022af95809
@@ -37,6 +37,8 @@
 #include "protocols/irc.h"
 #include "protocols/xmpp.h"
 #include "protocols/myspace.h"
+#include "protocols/qq.h"
+#include "protocols/simple.h"
 #include "blistsaving.h"
 #include "cmds.h"
 
@@ -717,6 +719,10 @@ void GlooxMessageHandler::loadProtocol()
 		m_protocol = (AbstractProtocol*) new XMPPProtocol(this);
 	else if (configuration().protocol == "myspace")
 		m_protocol = (AbstractProtocol*) new MyspaceProtocol(this);
+	else if (configuration().protocol == "qq")
+		m_protocol = (AbstractProtocol*) new QQProtocol(this);
+	else if (configuration().protocol == "simple")
+		m_protocol = (AbstractProtocol*) new SimpleProtocol(this);
 	if (!m_protocol->userSearchAction().empty()) {
 		m_searchHandler = new GlooxSearchHandler(this);
 		j->registerIqHandler(m_searchHandler, ExtSearch);


More information about the Commits mailing list