soc.2009.transport: 3aea4062: Adding missing files

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Tue Jun 9 13:15:28 EDT 2009


-----------------------------------------------------------------
Revision: 3aea4062a39f2324c1ca7bd93b5a7fdeac02baab
Ancestor: 7e3dc10a10a797b97bfb091331c5bed134aa8a2c
Author: hanzz at soc.pidgin.im
Date: 2009-06-09T17:10:46
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/3aea4062a39f2324c1ca7bd93b5a7fdeac02baab

Added files:
        muchandler.cpp muchandler.h protocols/irc.cpp
        protocols/irc.h
Modified files:
        schemas/mysql_schema.sql sql.cpp sql.h

ChangeLog: 

Adding missing files

-------------- next part --------------
============================================================
--- muchandler.cpp	8d54acda5f8db7f01bac9af4b7ed03da3f1a742d
+++ muchandler.cpp	8d54acda5f8db7f01bac9af4b7ed03da3f1a742d
@@ -0,0 +1,38 @@
+/**
+ * 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 "muchandler.h"
+#include "main.h"
+#include "user.h"
+
+MUCHandler::MUCHandler(User *user, const std::string &jid){
+	m_user = user;
+	m_jid = jid;
+}
+	
+MUCHandler::~MUCHandler() {}
+
+Tag * MUCHandler::handlePresence(const Presence &stanza) {
+// 	Presence tag(stanza.presence(), m_jid, stanza.status());
+// 	tag.setFrom(p->jid());
+
+// 	return tag.tag();
+	return NULL;
+}
\ No newline at end of file
============================================================
--- muchandler.h	5afad7f306ee4ddf2fbd423b99c1401800c22088
+++ muchandler.h	5afad7f306ee4ddf2fbd423b99c1401800c22088
@@ -0,0 +1,46 @@
+/**
+ * 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_MUCHANDLER_H
+#define _HI_MUCHANDLER_H
+
+#include "localization.h"
+#include "gloox/tag.h"
+#include "gloox/presence.h"
+
+class User;
+extern Localization localization;
+
+using namespace gloox;
+
+class MUCHandler
+{
+	public:
+		MUCHandler(User *user,const std::string &jid);
+		~MUCHandler();
+		Tag * handlePresence(const Presence &stanza);
+	
+	private:
+		User *m_user;
+		std::string m_jid;
+};
+
+#endif	
+	
\ No newline at end of file
============================================================
--- protocols/irc.cpp	2b5e1ef5f11c60b7fb6d53ebe30d21559b3a2bf2
+++ protocols/irc.cpp	2b5e1ef5f11c60b7fb6d53ebe30d21559b3a2bf2
@@ -0,0 +1,62 @@
+/**
+ * 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 "irc.h"
+#include "../main.h"
+
+IRCProtocol::IRCProtocol(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/commands");
+	m_transportFeatures.push_back("http://jabber.org/protocol/muc");
+	
+	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/commands");
+
+}
+	
+IRCProtocol::~IRCProtocol() {}
+
+std::list<std::string> IRCProtocol::transportFeatures(){
+	return m_transportFeatures;
+}
+
+std::list<std::string> IRCProtocol::buddyFeatures(){
+	return m_buddyFeatures;
+}
+
+std::string IRCProtocol::text(const std::string &key) {
+	if (key == "instructions")
+		return "Enter your Facebook email and password:";
+	return "not defined";
+}
+
+Tag *IRCProtocol::getVCardTag(User *user, GList *vcardEntries) {
+	PurpleNotifyUserInfoEntry *vcardEntry;
+
+	Tag *vcard = new Tag( "vCard" );
+	vcard->addAttribute( "xmlns", "vcard-temp" );
+
+	return vcard;
+}
+
============================================================
--- protocols/irc.h	6c18e4498924256062a92029bd8145a91aeca9f7
+++ protocols/irc.h	6c18e4498924256062a92029bd8145a91aeca9f7
@@ -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_IRCPROTOCOL_PROTOCOL_H
+#define _HI_IRCPROTOCOL_PROTOCOL_H
+
+#include "abstractprotocol.h"
+
+class GlooxMessageHandler;
+extern Localization localization;
+
+class IRCProtocol : AbstractProtocol
+{
+	public:
+		IRCProtocol(GlooxMessageHandler *main);
+		~IRCProtocol();
+		std::string gatewayIdentity() { return "conference"; }
+		std::string protocol() { return "prpl-irc"; }
+		bool isValidUsername(std::string &username) { return true; }
+		std::string prepareUserName(std::string &username) { return username; }
+		std::list<std::string> transportFeatures();
+		std::list<std::string> buddyFeatures();
+		std::string text(const std::string &key);
+		Tag *getVCardTag(User *user, GList *vcardEntries);
+		bool isMUC(User *user, const std::string &jid) { return true; }
+		
+	
+	private:
+		GlooxMessageHandler *m_main;
+		std::list<std::string> m_transportFeatures;
+		std::list<std::string> m_buddyFeatures;
+	
+};
+
+#endif	
+	
\ No newline at end of file
============================================================
--- schemas/mysql_schema.sql	98c03912ec58aa665c3c837036f19ff403e92553
+++ schemas/mysql_schema.sql	e9dd7d4104d3fb2c57382a8b3c90664aeaea7c01
@@ -26,6 +26,7 @@ CREATE TABLE `settings` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `jid` varchar(255) NOT NULL,
   `var` varchar(255) NOT NULL,
+  `type` tinyint(4) NOT NULL,
   `value` varchar(255) NOT NULL,
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
============================================================
--- sql.cpp	ff3df8968af4fc830d92acf4d407b2ff8d00671b
+++ sql.cpp	e7fcf6f5f428ef4849f11fa49ab6eb5404037051
@@ -328,6 +328,51 @@ void SQLClass::getRandomStatus(std::stri
 #endif
 }
 
+// settings
+
+void SQLClass::addSetting(const std::string &jid, const std::string &key, const std::string &value, int type) {
+	mysqlpp::Query query = sql->query();
+	query << "INSERT INTO "<< p->configuration().sqlPrefix <<"settings " << "(jid, var, type, value) VALUES (\"" << jid << "\",\"" << key << "\", \"" << type << "\", \"" << value << "\")";
+	query.execute();
+}
+
+void SQLClass::updateSetting(const std::string &jid, const std::string &key, const std::string &value, int type) {
+	mysqlpp::Query query = sql->query();
+	query << "UPDATE "<< p->configuration().sqlPrefix <<"settings SET value=\"" << value <<"\" WHERE jid=\"" << jid << "\" AND var=\"" << key << "\";";
+	query.execute();
+}
+
+void SQLClass::getSetting(const std::string &jid, const std::string &key) {
+	
+}
+
+void SQLClass::getSettings(const std::string &jid) {
+	GHashTable *settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+    mysqlpp::Query query = sql->query();
+#if MYSQLPP_HEADER_VERSION < 0x030000
+	mysqlpp::Result res;
+#else
+	mysqlpp::StoreQueryResult res;
+#endif
+    mysqlpp::Row row;
+
+    query << "SELECT * FROM "<< p->configuration().sqlPrefix <<"settings WHERE jid=\"" << jid << "\";";
+
+    res = query.store();
+#if MYSQLPP_HEADER_VERSION < 0x030000
+    if (res) {
+        if (row = res.fetch_row()) {
+            status = (std::string)row["reklama"];
+        }
+    }
+#else
+    if (res.num_rows() > 0) {
+        if (row = res[0]) {
+            status = (std::string)row["reklama"];
+        }
+    }
+#endif
+}
 			
 // SQLClass::~SQLClass(){
 //  	delete(sql);
============================================================
--- sql.h	f285872eec2f7639f2d4ab8b0b52a9705d43bd69
+++ sql.h	626d6f80eb5d33f41d6236e13baf260965a9e0d4
@@ -67,6 +67,13 @@ public:
 	long getRegisteredUsersCount();
 	long getRegisteredUsersRosterCount();
     void getRandomStatus(std::string & status);
+	
+	// settings
+	void addSetting(const std::string &jid, const std::string &key, const std::string &value, int type);
+	void updateSetting(const std::string &jid, const std::string &key, const std::string &value, int type);
+	void getSetting(const std::string &jid, const std::string &key);
+	GHashTable * getSettings(const std::string &jid);
+	
 	UserRow getUserByJid(const std::string &jid);
 	std::map<std::string,RosterRow> getRosterByJid(const std::string &jid);
 	std::map<std::string,RosterRow> getRosterByJidAsk(const std::string &jid);


More information about the Commits mailing list