soc.2009.transport: 0a47c624: Added and tested AIM support

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Mon Jul 20 11:40:30 EDT 2009


-----------------------------------------------------------------
Revision: 0a47c624c7f76b0a12433f9d51f6dd523e8a94f6
Ancestor: 9038ae13210055767b8d711069d77c883b2c7636
Author: hanzz at soc.pidgin.im
Date: 2009-07-20T15:35:03
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/0a47c624c7f76b0a12433f9d51f6dd523e8a94f6

Added files:
        protocols/aim.cpp protocols/aim.h
Modified files:
        CMakeLists.txt main.cpp

ChangeLog: 

Added and tested AIM support

-------------- next part --------------
============================================================
--- protocols/aim.cpp	d5b0d6a9daaeb12560257cb6828ef3a6c14ed372
+++ protocols/aim.cpp	d5b0d6a9daaeb12560257cb6828ef3a6c14ed372
@@ -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 "aim.h"
+#include "../main.h"
+
+AIMProtocol::AIMProtocol(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");
+}
+	
+AIMProtocol::~AIMProtocol() {}
+
+std::string AIMProtocol::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 AIMProtocol::prepareUserName(std::string &str){
+	str = replace(str," ","");
+	return str;
+}
+
+bool AIMProtocol::isValidUsername(std::string &str){
+	// TODO: check valid email address
+	return true;
+}
+
+std::list<std::string> AIMProtocol::transportFeatures(){
+	return m_transportFeatures;
+}
+
+std::list<std::string> AIMProtocol::buddyFeatures(){
+	return m_buddyFeatures;
+}
+
+std::string AIMProtocol::text(const std::string &key) {
+	if (key == "instructions")
+		return "Enter your screenname and password:";
+	return "not defined";
+}
============================================================
--- protocols/aim.h	11d4b2086347b2ef60d06ca3107bf8ec95dfc9c0
+++ protocols/aim.h	11d4b2086347b2ef60d06ca3107bf8ec95dfc9c0
@@ -0,0 +1,53 @@
+/**
+ * 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_AIM_PROTOCOL_H
+#define _HI_AIM_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+
+class AIMProtocol : AbstractProtocol
+{
+	public:
+		AIMProtocol(GlooxMessageHandler *main);
+		~AIMProtocol();
+		std::string gatewayIdentity() { return "aim"; }
+		std::string protocol() { return "prpl-aim"; }
+		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 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	8372f21cf74bede1ad78d84681b5984e8f6aecc7
+++ CMakeLists.txt	1b5eca6461e000faefe34bc41979a8f7dd2a5130
@@ -107,6 +107,7 @@
 	protocols/qq.cpp
 	protocols/simple.cpp
 	protocols/yahoo.cpp
+	protocols/aim.cpp
 )
 
 set(hiicq_MOC_HDRS
@@ -152,6 +153,7 @@
 	protocols/qq.h
 	protocols/simple.h
 	protocols/yahoo.h
+	protocols/aim.h
 )
 
 add_executable(hiicq ${hiicq_SRCS} ${lrelease_outputs})
============================================================
--- main.cpp	962598b1b4a71e4efd3e3091c08aebc2c1fe9d4b
+++ main.cpp	fa32f806c1d5560a8dc7c5dbd68560fc684d12e0
@@ -40,6 +40,7 @@
 #include "protocols/myspace.h"
 #include "protocols/qq.h"
 #include "protocols/simple.h"
+#include "protocols/aim.h"
 #include "blistsaving.h"
 #include "cmds.h"
 
@@ -657,6 +658,8 @@ void GlooxMessageHandler::loadProtocol()
 		m_protocol = (AbstractProtocol*) new QQProtocol(this);
 	else if (configuration().protocol == "simple")
 		m_protocol = (AbstractProtocol*) new SimpleProtocol(this);
+	else if (configuration().protocol == "aim")
+		m_protocol = (AbstractProtocol*) new AIMProtocol(this);
 	if (!m_protocol->userSearchAction().empty()) {
 		m_searchHandler = new GlooxSearchHandler(this);
 		j->registerIqHandler(m_searchHandler, ExtSearch);


More information about the Commits mailing list