soc.2009.transport: fa5af6f6: Added GlooxParser class. It allows to cr...

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Sat Jun 27 11:30:37 EDT 2009


-----------------------------------------------------------------
Revision: fa5af6f634857afd36945d0b22de4c58e0a1649f
Ancestor: 24b9cb2fdeabf02000876fd202df714b6d201f2e
Author: hanzz at soc.pidgin.im
Date: 2009-06-27T15:25:31
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/fa5af6f634857afd36945d0b22de4c58e0a1649f

Modified files:
        CMakeLists.txt main.cpp main.h user.cpp

ChangeLog: 

Added GlooxParser class. It allows to create gloox::Tag from std::string

-------------- next part --------------
============================================================
--- CMakeLists.txt	9c21f6d33a8d1ded00417f5d57a4c8c18c0e8d4c
+++ CMakeLists.txt	39d5c61bdbb95f3b5812d638d22e8c64c854af34
@@ -94,6 +94,7 @@
 	searchhandler.cpp
 	searchrepeater.cpp
 	dataforms.cpp
+	parser.cpp
 	protocols/icq.cpp
 	protocols/facebook.cpp
 	protocols/gg.cpp
@@ -132,6 +133,7 @@
 	searchrepeater.h
 	abstractpurplerequest.h
 	dataforms.h
+	parser.h
 	protocols/abstractprotocol.h
 	protocols/icq.h
 	protocols/facebook.h
============================================================
--- main.cpp	858c56c9bb00faf797e75e46ab58c6eeb32b4a9e
+++ main.cpp	4c19d73fd5a5a82972e578fe84eca8d0ec8ac2d1
@@ -28,6 +28,7 @@
 #include "adhocrepeater.h"
 #include "searchhandler.h"
 #include "searchrepeater.h"
+#include "parser.h"
 #include "protocols/abstractprotocol.h"
 #include "protocols/icq.h"
 #include "protocols/facebook.h"
@@ -636,8 +637,6 @@ GlooxMessageHandler::GlooxMessageHandler
 	Log().Get("gloox") << "connecting to: " << m_configuration.server << " as " << m_configuration.jid << " with password " << m_configuration.password;
 	j = new HiComponent("jabber:component:accept",m_configuration.server,m_configuration.jid,m_configuration.password,m_configuration.port);
 
-	parser = new Parser(this);
-
 	GMainLoop *loop = g_main_loop_new(NULL, FALSE);
 	signal(SIGCHLD, SIG_IGN);
 
@@ -655,6 +654,7 @@ GlooxMessageHandler::GlooxMessageHandler
  	j->registerIqHandler(m_discoInfoHandler,ExtDiscoInfo);
 	
 	m_adhoc = new GlooxAdhocHandler(this);
+	m_parser = new GlooxParser();
 	
 	ftManager = new FileTransferManager();
 	ft = new SIProfileFT(j, ftManager );
@@ -693,6 +693,7 @@ GlooxMessageHandler::~GlooxMessageHandle
 
 GlooxMessageHandler::~GlooxMessageHandler(){
 	delete m_userManager;
+	delete m_parser;
 	delete j;
 	j=NULL;
 	purple_core_quit();
@@ -1306,10 +1307,6 @@ bool GlooxMessageHandler::onTLSConnect(c
 	return false;
 }
 
-void GlooxMessageHandler::handleTag (Tag *tag) {
-	m_handleTagCallback(tag, m_userdata);
-}
-
 void GlooxMessageHandler::handleMessage (const Message &msg, MessageSession *session) {
 	if (msg.from().bare() == msg.to().bare())
 		return;
============================================================
--- main.h	45ab628553f099d9f250f84819edfe11460088aa
+++ main.h	d1d93d6f021151a2c38cdae40b849a3ab82c00f6
@@ -98,6 +98,7 @@ class GlooxSearchHandler;
 // class AdhocHandler;
 class AdhocRepeater;
 class GlooxSearchHandler;
+class GlooxParser;
 
 struct User;
 struct UserRow;
@@ -146,7 +147,7 @@ struct Configuration {
 	std::string sqlPrefix;	// mysql prefix used for tables
 };
 
-class GlooxMessageHandler : public MessageHandler,ConnectionListener,PresenceHandler,SubscriptionHandler, TagHandler
+class GlooxMessageHandler : public MessageHandler,ConnectionListener,PresenceHandler,SubscriptionHandler
 {
 
 public:
@@ -174,9 +175,6 @@ public:
 	void purpleFileReceiveComplete(PurpleXfer *xfer);
 	void notifyEmail(PurpleConnection *gc,const char *subject, const char *from,const char *to, const char *url);
 
-	// TagHandler
-	void handleTag (Tag *tag);
-
 	// MessageHandler
 	void handleMessage (const Message &msg, MessageSession *session=0);
 
@@ -196,8 +194,6 @@ public:
 	bool hasCaps(const std::string &name);
 	void removeUser(User *user);
 	
-	Parser *parser;
-	
 	UserManager *userManager() { return m_userManager; }
 	GlooxStatsHandler *stats() { return m_stats; }
 	Configuration & configuration() { return m_configuration; }
@@ -207,6 +203,7 @@ public:
 	AbstractProtocol *protocol() { return m_protocol; }
 	GlooxAdhocHandler *adhoc() { return m_adhoc; }
 	GlooxSearchHandler *searchHandler() { return m_searchHandler; }
+	GlooxParser *parser() { return m_parser; }
 	
 	FileTransferManager* ftManager;
 	SIProfileFT* ft;
@@ -221,9 +218,6 @@ public:
 	GlooxGatewayHandler *gatewayHandler;
 	SOCKS5BytestreamServer* ftServer;
 
-	void (*m_handleTagCallback)(Tag *tag, Tag *user_data);
-	Tag *m_userdata;
-
 private:
 // 	bool callback(GIOCondition condition);
 	bool initPurple();
@@ -244,6 +238,7 @@ private:
 	GlooxSearchHandler *m_searchHandler;
 // 	std::list <GlooxAdhocHandler *> m_adhoc_handlers;
 	GlooxAdhocHandler *m_adhoc;
+	GlooxParser *m_parser;
 	
 	GIOChannel *connectIO;
 	
============================================================
--- user.cpp	da160c0d99b83f69501fa3924a6225af6e9c59e7
+++ user.cpp	d5cc5efc3d645145513508be6588ff4c8768db97
@@ -26,6 +26,7 @@
 #include "gloox/chatstate.h"
 #include "muchandler.h"
 #include "cmds.h"
+#include "parser.h"
 
 /*
  * Called when contact list has been received from legacy network.
@@ -595,11 +596,7 @@ void User::purpleConversationWriteIM(Pur
 	}
 	Log().Get("TEST") << m << " " << message;
 	if (hasFeature(GLOOX_FEATURE_XHTML_IM) && m != message) {
-		p->m_userdata = stanzaTag;
-		p->m_handleTagCallback = sendXhtmlTag;
-		
-		p->parser->cleanup();
-		p->parser->feed(m);
+		p->parser()->getTag(m, sendXhtmlTag, stanzaTag);
 		g_free(newline);
 		g_free(strip);
 		return;


More information about the Commits mailing list