soc.2009.transport: 7e80eca1: Added support for Myspace.
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Wed Jul 1 09:25:44 EDT 2009
-----------------------------------------------------------------
Revision: 7e80eca1f01c6ea39e8df620b4a2c9a6d8e91bb3
Ancestor: 080f4c8c43bb246efa39e7500529b61abee7d7b7
Author: hanzz at soc.pidgin.im
Date: 2009-07-01T13:19:25
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/7e80eca1f01c6ea39e8df620b4a2c9a6d8e91bb3
Added files:
protocols/myspace.cpp protocols/myspace.h
Modified files:
CMakeLists.txt main.cpp
ChangeLog:
Added support for Myspace.
-------------- next part --------------
============================================================
--- protocols/myspace.cpp 71f20c57506affaccb875068693b1b94be4a5d63
+++ protocols/myspace.cpp 71f20c57506affaccb875068693b1b94be4a5d63
@@ -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 "myspace.h"
+#include "../main.h"
+
+MyspaceProtocol::MyspaceProtocol(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");
+}
+
+MyspaceProtocol::~MyspaceProtocol() {}
+
+std::string MyspaceProtocol::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 MyspaceProtocol::prepareUserName(std::string &str){
+ str = replace(str," ","");
+ return str;
+}
+
+bool MyspaceProtocol::isValidUsername(std::string &str){
+ // TODO: check valid email address
+ return true;
+}
+
+std::list<std::string> MyspaceProtocol::transportFeatures(){
+ return m_transportFeatures;
+}
+
+std::list<std::string> MyspaceProtocol::buddyFeatures(){
+ return m_buddyFeatures;
+}
+
+std::string MyspaceProtocol::text(const std::string &key) {
+ if (key == "instructions")
+ return "Enter your Myspace name and password:";
+ return "not defined";
+}
============================================================
--- protocols/myspace.h 290823f72ab052ab7d281372d1e31832d6deeeb4
+++ protocols/myspace.h 290823f72ab052ab7d281372d1e31832d6deeeb4
@@ -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_MYSPACE_PROTOCOL_H
+#define _HI_MYSPACE_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+extern Localization localization;
+
+class MyspaceProtocol : AbstractProtocol
+{
+ public:
+ MyspaceProtocol(GlooxMessageHandler *main);
+ ~MyspaceProtocol();
+ std::string gatewayIdentity() { return "myspace"; }
+ std::string protocol() { return "prpl-myspace"; }
+ 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 39d5c61bdbb95f3b5812d638d22e8c64c854af34
+++ CMakeLists.txt 7e1f448ef45d8e5867cc64b0f6ecaf657e4d9f67
@@ -101,6 +101,7 @@
protocols/msn.cpp
protocols/irc.cpp
protocols/xmpp.cpp
+ protocols/myspace.cpp
)
set(hiicq_MOC_HDRS
@@ -141,6 +142,7 @@
protocols/msn.h
protocols/irc.h
protocols/xmpp.h
+ protocols/myspace.h
)
add_executable(hiicq ${hiicq_SRCS} ${lrelease_outputs})
============================================================
--- main.cpp ff374ca50fa920b9acd3834fafbdff313e639b82
+++ main.cpp e6a2e3464003b85f259a0e7ec3b06eb71b1c8666
@@ -36,6 +36,7 @@
#include "protocols/msn.h"
#include "protocols/irc.h"
#include "protocols/xmpp.h"
+#include "protocols/myspace.h"
#include "blistsaving.h"
#include "cmds.h"
@@ -714,6 +715,8 @@ void GlooxMessageHandler::loadProtocol()
m_protocol = (AbstractProtocol*) new IRCProtocol(this);
else if (configuration().protocol == "xmpp")
m_protocol = (AbstractProtocol*) new XMPPProtocol(this);
+ else if (configuration().protocol == "myspace")
+ m_protocol = (AbstractProtocol*) new MyspaceProtocol(this);
if (!m_protocol->userSearchAction().empty()) {
m_searchHandler = new GlooxSearchHandler(this);
j->registerIqHandler(m_searchHandler, ExtSearch);
More information about the Commits
mailing list