soc.2009.transport: 434beba7: Use of Gloox-1.x instead of my own patch...

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Fri May 29 04:55:29 EDT 2009


-----------------------------------------------------------------
Revision: 434beba783e3117e8ce853f3cf0031d4337ab8ec
Ancestor: 76da5feb3d5626935771e186b2153c0327ae5c1e
Author: hanzz at soc.pidgin.im
Date: 2009-05-29T08:52:41
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/434beba783e3117e8ce853f3cf0031d4337ab8ec

Modified files:
        adhochandler.cpp adhochandler.h adhocrepeater.cpp
        adhocrepeater.h autoconnectloop.cpp caps.cpp caps.h
        discoinfohandler.cpp discoinfohandler.h
        filetransfermanager.cpp filetransfermanager.h
        gatewayhandler.cpp gatewayhandler.h main.cpp main.h
        receivefile.cpp registerhandler.cpp registerhandler.h
        sendfile.cpp statshandler.cpp statshandler.h user.cpp user.h
        vcardhandler.cpp vcardhandler.h xpinghandler.cpp
        xpinghandler.h

ChangeLog: 

Use of Gloox-1.x instead of my own patched version. Filetransfer and Adhoc commands are broken since this commit.

-------------- next part --------------
============================================================
--- adhochandler.cpp	f487be801da13789e79eced10a1713e2c43d4e41
+++ adhochandler.cpp	43cd1f2292250d82ea4f889c4e4917c245b21d73
@@ -22,10 +22,11 @@
  #include "usermanager.h"
  #include "log.h"
  #include "adhocrepeater.h"
+ #include "gloox/disconodehandler.h"
  
 AdhocHandler::AdhocHandler(GlooxMessageHandler *m) {
 	main = m;
-	main->j->registerIqHandler( this, XMLNS_ADHOC_COMMANDS );
+	main->j->registerIqHandler( this, ExtAdhocCommand );
 	main->j->disco()->addFeature( XMLNS_ADHOC_COMMANDS );
 	main->j->disco()->registerNodeHandler( this, XMLNS_ADHOC_COMMANDS );
 	main->j->disco()->registerNodeHandler( this, std::string() );
@@ -34,22 +35,20 @@ AdhocHandler::~AdhocHandler() { }
 
 AdhocHandler::~AdhocHandler() { }
 
-StringList AdhocHandler::handleDiscoNodeFeatures( const std::string& /*node*/ ) {
+StringList AdhocHandler::handleDiscoNodeFeatures (const JID &from, const std::string &node) {
 	StringList features;
 	features.push_back( XMLNS_ADHOC_COMMANDS );
 	return features;
 }
 
-DiscoNodeItemList AdhocHandler::handleDiscoNodeItems( const std::string &from, const std::string &to, const std::string& node ) {
-	DiscoNodeItemList lst;
-	if (node.empty()) {
-		DiscoNodeItem item;
-		item.node = XMLNS_ADHOC_COMMANDS;
-		item.jid = main->jid();
-		item.name = "Ad-Hoc Commands";
-		lst.push_back( item );
-	}
-	else if (node == XMLNS_ADHOC_COMMANDS) {
+Disco::ItemList AdhocHandler::handleDiscoNodeItems( const JID &_from, const JID &_to, const std::string& node ) {
+	Disco::ItemList lst;
+	std::string from = _from.bare();
+	std::string to = _to.bare();
+// 	if (node.empty()) {
+// 		lst.push_back( new Disco::Item( main->jid(), XMLNS_ADHOC_COMMANDS, "Ad-Hoc Commands" ) );
+// 	}
+// 	else if (node == XMLNS_ADHOC_COMMANDS) {
 		if (to == main->jid()) {
 			User *user = main->userManager()->getUserByJID(from);
 			if (user) {
@@ -65,12 +64,8 @@ DiscoNodeItemList AdhocHandler::handleDi
 						for (l = actions; l != NULL; l = l->next) {
 							if (l->data) {
 								action = (PurplePluginAction *) l->data;
-								DiscoNodeItem item;
-								item.node = (std::string) action->label;
-								item.jid = main->jid();
-								item.name = (std::string) action->label;
+								lst.push_back( new Disco::Item( main->jid(), (std::string) action->label, (std::string) action->label ) );
 								purple_plugin_action_free(action);
-								lst.push_back( item );
 							}
 						}
 					}
@@ -93,44 +88,35 @@ DiscoNodeItemList AdhocHandler::handleDi
 
 					for(l = ll = prpl_info->blist_node_menu((PurpleBlistNode*)buddy); l; l = l->next) {
 						PurpleMenuAction *action = (PurpleMenuAction *) l->data;
-						DiscoNodeItem item;
-						item.node = (std::string) action->label;
-						item.jid = to + "/bot";
-						item.name = (std::string) action->label;
+						lst.push_back( new Disco::Item( main->jid(), (std::string) action->label, (std::string) action->label ) );
 						purple_menu_action_free(action);
-						lst.push_back( item );
 					}
 				}
 			}
 		}
-	}
+// 	}
 	return lst;
 }
 
-StringMap AdhocHandler::handleDiscoNodeIdentities( const std::string& node, std::string& name ) {
-	name = (std::string) node;
-
-	StringMap ident;
-	if( node == XMLNS_ADHOC_COMMANDS )
-		ident["automation"] = "command-list";
-	else
-		ident["automation"] = "command-node";
-	return ident;
+Disco::IdentityList AdhocHandler::handleDiscoNodeIdentities( const JID& jid, const std::string& node ) {
+	Disco::IdentityList l;
+	l.push_back( new Disco::Identity( "automation",node == XMLNS_ADHOC_COMMANDS ? "command-list" : "command-node",node == XMLNS_ADHOC_COMMANDS ? "Ad-Hoc Commands" : "") );
+	return l;
 }
 
-bool AdhocHandler::handleIq( Stanza *stanza ) {
+bool AdhocHandler::handleIq( const IQ &stanza ) {
 	Log().Get("AdhocHandler") << "handleIq";
-	std::string to = stanza->to().bare();
-	std::string from = stanza->from().bare();
-	Tag *tag = stanza->findChild( "command" );
+	std::string to = stanza.to().bare();
+	std::string from = stanza.from().bare();
+	Tag *tag = stanza.tag()->findChild( "command" );
 	const std::string& node = tag->findAttribute( "node" );
 	if (node.empty()) return false;
 
 	User *user = main->userManager()->getUserByJID(from);
 	if (user) {
 		if (user->isConnected() && purple_account_get_connection(user->account())) {
-			if (hasSession(stanza->from().full())) {
-				return m_sessions[stanza->from().full()]->handleIq(stanza);
+			if (hasSession(stanza.from().full())) {
+				return m_sessions[stanza.from().full()]->handleIq(stanza);
 			}
 			else if (to == main->jid()) {
 				PurpleConnection *gc = purple_account_get_connection(user->account());
@@ -146,8 +132,8 @@ bool AdhocHandler::handleIq( Stanza *sta
 							action = (PurplePluginAction *) l->data;
 							if (node == (std::string) action->label) {
 								AdhocData data;
-								data.id = stanza->id();
-								data.from = stanza->from().full();
+								data.id = stanza.id();
+								data.from = stanza.from().full();
 								data.node = node;
 								user->setAdhocData(data);
 								action->plugin = plugin;
@@ -177,15 +163,16 @@ bool AdhocHandler::handleIq( Stanza *sta
 						if (callback)
 							callback((PurpleBlistNode*)buddy, action->data);
 
-						Stanza *response = Stanza::createIqStanza(stanza->from().full(), stanza->id(), StanzaIqResult, "", 0);
-						response->addAttribute("from", main->jid());
+						IQ _s(IQ::Result, stanza.from().full(), stanza.id());
+						_s.setFrom(main->jid());
+						Tag *s = _s.tag();
 
 						Tag *c = new Tag("command");
 						c->addAttribute("xmlns","http://jabber.org/protocol/commands");
 						c->addAttribute("sessionid",tag->findAttribute("sessionid"));
 						c->addAttribute("node","configuration");
 						c->addAttribute("status","completed");
-						main->j->send(response);
+						main->j->send(s);
 
 					}
 					purple_menu_action_free(action);
@@ -204,20 +191,11 @@ bool AdhocHandler::hasSession(const std:
 	return false;
 }
 
-bool AdhocHandler::handleIqID( Stanza *stanza, int context ) {
-	return true;
+void AdhocHandler::handleIqID( const IQ &iq, int context ) {
 }
 
-void AdhocHandler::handleDiscoInfoResult( Stanza *stanza, int context ) {
-	
-}
+void AdhocHandler::handleDiscoInfo(const JID &jid, const Disco::Info &info, int context) {}
+void AdhocHandler::handleDiscoItems(const JID &jid, const Disco::Items &items, int context) {}
+void AdhocHandler::handleDiscoError(const JID &jid, const Error *error, int context) {}
 
-void AdhocHandler::handleDiscoItemsResult( Stanza *stanza, int context ) {
-	
-}
 
-void AdhocHandler::handleDiscoError( Stanza *stanza, int context ) {
-	
-}
-
-
============================================================
--- adhochandler.h	8d353c41e537cd38021048c96bbef2462f80f078
+++ adhochandler.h	f56c6db2bb4ac45a45f88102743cd9331d3fd493
@@ -25,6 +25,7 @@
 #include "account.h"
 #include "user.h"
 #include "glib.h"
+#include "gloox/disconodehandler.h"
 
 class GlooxMessageHandler;
 class AdhocRepeater;
@@ -34,14 +35,14 @@ class AdhocHandler : public DiscoNodeHan
 	public:
 		AdhocHandler(GlooxMessageHandler *m);
 		~AdhocHandler();
-		virtual StringList handleDiscoNodeFeatures( const std::string& node );
-		virtual StringMap handleDiscoNodeIdentities( const std::string& node, std::string& name );
-		virtual DiscoNodeItemList handleDiscoNodeItems( const std::string &from, const std::string &to, const std::string& node );
-		virtual bool handleIq( Stanza *stanza );
-		virtual bool handleIqID( Stanza *stanza, int context );
-		virtual void handleDiscoInfoResult( Stanza *stanza, int context );
-		virtual void handleDiscoItemsResult( Stanza *stanza, int context );
-		virtual void handleDiscoError( Stanza *stanza, int context );
+		StringList handleDiscoNodeFeatures (const JID &from, const std::string &node);
+		Disco::IdentityList handleDiscoNodeIdentities( const JID& jid, const std::string& node );
+		Disco::ItemList handleDiscoNodeItems (const JID &from, const JID &to, const std::string &node=EmptyString);
+		bool handleIq (const IQ &iq);
+		void handleIqID (const IQ &iq, int context);
+		void handleDiscoInfo(const JID &jid, const Disco::Info &info, int context);
+		void handleDiscoItems(const JID &jid, const Disco::Items &items, int context);
+		void handleDiscoError(const JID &jid, const Error *error, int context);
 		void registerSession(const std::string &jid, AdhocRepeater *repeater) {std::cout << jid << "\n"; m_sessions[jid] = repeater; }
 		void unregisterSession(std::string &jid) { m_sessions.erase(jid); }
 		bool hasSession(const std::string &jid);
============================================================
--- adhocrepeater.cpp	b366b997ee2248994b746574c04afc3143e690b5
+++ adhocrepeater.cpp	50cf4f147d520a735176396e88b52862f1a6864c
@@ -38,7 +38,8 @@ AdhocRepeater::AdhocRepeater(GlooxMessag
 	AdhocData data = user->adhocData();
 	m_from = data.from;
 	
-	Stanza *response = Stanza::createIqStanza(data.from,data.id,StanzaIqResult,"",0);
+	IQ _response(IQ::Result, data.from, data.id);
+	Tag *response = _response.tag();
 	response->addAttribute("from",main->jid());
 
 	Tag *c = new Tag("command");
@@ -76,11 +77,12 @@ AdhocRepeater::~AdhocRepeater() {}
 
 AdhocRepeater::~AdhocRepeater() {}
 
-bool AdhocRepeater::handleIq(Stanza *stanza) {
-	Tag *tag = stanza->findChild( "command" );
+bool AdhocRepeater::handleIq(const IQ &stanza) {
+	Tag *tag = stanza.tag()->findChild( "command" );
 	if (tag->hasAttribute("action","cancel")){
-		Stanza *response = Stanza::createIqStanza(stanza->from().full(), stanza->id(), StanzaIqResult, "", 0);
-		response->addAttribute("from", main->jid());
+		IQ _response(IQ::Result, stanza.from().full(), stanza.id());
+		_response.setFrom(main->jid());
+		Tag *response = _response.tag();
 
 		Tag *c = new Tag("command");
 		c->addAttribute("xmlns","http://jabber.org/protocol/commands");
@@ -97,7 +99,7 @@ bool AdhocRepeater::handleIq(Stanza *sta
 	Tag *x = tag->findChildWithAttrib("xmlns","jabber:x:data");
 	if (x) {
 		std::string result("");
-		for(std::list<Tag*>::iterator it = x->children().begin(); it != x->children().end(); ++it){
+		for(std::list<Tag*>::const_iterator it = x->children().begin(); it != x->children().end(); ++it){
 			if ((*it)->hasAttribute("var","result")){
 				result = (*it)->findChild("value")->cdata();
 				break;
@@ -106,15 +108,16 @@ bool AdhocRepeater::handleIq(Stanza *sta
 
 		((PurpleRequestInputCb) m_ok_cb)(m_requestData, result.c_str());
 
-		Stanza *response = Stanza::createIqStanza(stanza->from().full(), stanza->id(), StanzaIqResult, "", 0);
-		response->addAttribute("from", main->jid());
+		IQ _s(IQ::Result, stanza.from().full(), stanza.id());
+		_s.setFrom(main->jid());
+		Tag *s = _s.tag();
 
 		Tag *c = new Tag("command");
 		c->addAttribute("xmlns","http://jabber.org/protocol/commands");
 		c->addAttribute("sessionid",tag->findAttribute("sessionid"));
 		c->addAttribute("node","configuration");
 		c->addAttribute("status","completed");
-		main->j->send(response);
+		main->j->send(s);
 	}
 
 
============================================================
--- adhocrepeater.h	c0809861364980a88ea37abfba4e35af5b4e3f09
+++ adhocrepeater.h	457931567b69af928520c11067afc19b44f71744
@@ -35,7 +35,7 @@ class AdhocRepeater
 	public:
 		AdhocRepeater(GlooxMessageHandler *m, User *user, const std::string &title, const std::string &primaryString, const std::string &secondaryString, const std::string &value, gboolean multiline, gboolean masked, GCallback ok_cb, GCallback cancel_cb, void * user_data);
 		~AdhocRepeater();
-		bool handleIq(Stanza *stanza);
+		bool handleIq(const IQ &iq);
 		void setType(PurpleRequestType t) { m_type = t; }
 		PurpleRequestType type() { return m_type; }
 		std::string from() { return m_from; }
============================================================
--- autoconnectloop.cpp	10c31ab28140a30d201953b05b43106edb8ee9f9
+++ autoconnectloop.cpp	d36c170533f24c7306da34802e1b972f5d05b913
@@ -61,7 +61,7 @@ bool AutoConnectLoop::restoreNextConnect
 }
 
 bool AutoConnectLoop::restoreNextConnection() {
-	Stanza * stanza;
+// 	Stanza * stanza;
 	User *user;
 	PurpleAccount *account;
 	Log().Get("connection restorer") << "Restoring new connection";
@@ -75,7 +75,7 @@ bool AutoConnectLoop::restoreNextConnect
 		user = main->userManager()->getUserByAccount(account);
 		if (user == NULL) {
 			Log().Get("connection restorer") << "Sending probe presence to "<< JID((std::string)purple_account_get_string(account,"lastUsedJid","")).bare();
-			stanza = new Stanza("presence");
+			Tag *stanza = new Tag("presence");
 			stanza->addAttribute( "to", JID((std::string)purple_account_get_string(account,"lastUsedJid","")).bare());
 			stanza->addAttribute( "type", "probe");
 			stanza->addAttribute( "from", main->jid());
============================================================
--- caps.cpp	e63f4326874e736659c34508fb544daf3e475a76
+++ caps.cpp	3c878dff7896ed1a85825accbc31ac0ddc6c304f
@@ -27,29 +27,35 @@ GlooxDiscoHandler::GlooxDiscoHandler(Glo
 
 GlooxDiscoHandler::GlooxDiscoHandler(GlooxMessageHandler *parent) : DiscoHandler(){
 	p=parent;
+	version = 0;
 }
 
 GlooxDiscoHandler::~GlooxDiscoHandler(){
 }
 
-bool GlooxDiscoHandler::hasVersion(const std::string &name){
-	std::map<std::string,std::string> ::iterator iter = versions.begin();
+bool GlooxDiscoHandler::hasVersion(int name){
+	std::map<int,std::string> ::iterator iter = versions.begin();
 	iter = versions.find(name);
 	if(iter != versions.end())
 		return true;
 	return false;
 }
 
-void GlooxDiscoHandler::handleDiscoInfoResult(Stanza *stanza,int context){
-	if (stanza->id().empty())
+// 	void handleDiscoInfo(const JID &jid, const Disco::Info &info, int context);
+// 	void handleDiscoItems(const JID &jid, const Disco::Items &items, int context);
+// 	void handleDiscoError(const JID &jid, const Error *error, int context);
+
+void GlooxDiscoHandler::handleDiscoInfo(const JID &jid, const Disco::Info &info, int context) {
+// 	if (stanza->id().empty())
+// 		return;
+	if (!hasVersion(context))
 		return;
-	if (!hasVersion(stanza->id()))
-		return;
-	Tag *query = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
-	if (query==NULL)
-		return;
+// 	Tag *query = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
+// 	if (query==NULL)
+// 		return;
 	//if (query->findChild("identity") && query->findChild("identity")->findChild("category") && !query->findChild("identity")->findChildWithAttrib("category","client"))
 		//return;
+	Tag *query = info.tag();
 	if (query->findChild("identity") && !query->findChildWithAttrib("category","client"))
 		return;
 	int feature=0;
@@ -70,49 +76,49 @@ void GlooxDiscoHandler::handleDiscoInfoR
 			}
 		}
 	std::cout << "*** FEATURES ARRIVED: " << feature << "\n";
-	p->capsCache[versions[stanza->id()]]=feature;
-	User *user = p->userManager()->getUserByJID(stanza->from().bare());
+	p->capsCache[versions[context]]=feature;
+	User *user = p->userManager()->getUserByJID(jid.bare());
 	if (user==NULL){
 		std::cout << "no user?! wtf...";
 	}
 	else{
 		if (user->capsVersion().empty()){
-			user->setCapsVersion(versions[stanza->id()]);
+			user->setCapsVersion(versions[context]);
 			if (user->readyForConnect())
 				user->connect();
 		}
 	}
 	// TODO: CACHE CAPS IN DATABASE ACCORDING TO VERSION
-	versions.erase(stanza->id());
+	versions.erase(context);
 }
 
-void GlooxDiscoHandler::handleDiscoItemsResult(Stanza *stanza,int context){
+void GlooxDiscoHandler::handleDiscoItems(const JID &jid, const Disco::Items &items, int context){
 
 }
 
-void GlooxDiscoHandler::handleDiscoError(Stanza *stanza,int context){
-	if (stanza->id().empty())
-		return;
-	if (!hasVersion(stanza->id()))
-		return;
-	Tag *query = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
-	if (query==NULL)
-		return;
-	// we are now using timeout
-	return;
-	int feature=0;
-	p->capsCache[versions[stanza->id()]]=feature;
-	std::cout << "*** FEATURES ERROR received: " << feature << "\n";
-	User *user = p->userManager()->getUserByJID(stanza->from().bare());
-	if (user==NULL){
-		std::cout << "no user?! wtf...";
-	}
-	else{
-		if (user->capsVersion().empty()){
-			user->setCapsVersion(versions[stanza->id()]);
-			if (user->readyForConnect())
-				user->connect();
-		}
-	}
-	versions.erase(stanza->id());
+void GlooxDiscoHandler::handleDiscoError(const JID &jid, const Error *error, int context){
+// // 	if (stanza->id().empty())
+// // 		return;
+// // 	if (!hasVersion(context))
+// // 		return;
+// // 	Tag *query = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
+// // 	if (query==NULL)
+// // 		return;
+// 	// we are now using timeout
+// 	return;
+// 	int feature=0;
+// 	p->capsCache[versions[stanza->id()]]=feature;
+// 	std::cout << "*** FEATURES ERROR received: " << feature << "\n";
+// 	User *user = p->userManager()->getUserByJID(stanza->from().bare());
+// 	if (user==NULL){
+// 		std::cout << "no user?! wtf...";
+// 	}
+// 	else{
+// 		if (user->capsVersion().empty()){
+// 			user->setCapsVersion(versions[stanza->id()]);
+// 			if (user->readyForConnect())
+// 				user->connect();
+// 		}
+// 	}
+// 	versions.erase(stanza->id());
 }
============================================================
--- caps.h	6e221babafea8f5b312ad8a9bf169209bf87bfa8
+++ caps.h	6dc86197fa2aac623e4d20af98540d936806bfb7
@@ -42,12 +42,16 @@ public:
 public:
 	GlooxDiscoHandler(GlooxMessageHandler *parent);
 	~GlooxDiscoHandler();
-	void handleDiscoInfoResult(Stanza *stanza,int context);
-	void handleDiscoItemsResult(Stanza *stanza,int context);
-	void handleDiscoError(Stanza *stanza,int context);
-	bool hasVersion(const std::string &name);
+// 	void handleDiscoInfoResult(Stanza *stanza,int context);
+// 	void handleDiscoItemsResult(Stanza *stanza,int context);
+// 	void handleDiscoError(Stanza *stanza,int context);
+	void handleDiscoInfo(const JID &jid, const Disco::Info &info, int context);
+	void handleDiscoItems(const JID &jid, const Disco::Items &items, int context);
+	void handleDiscoError(const JID &jid, const Error *error, int context);
+	bool hasVersion(int i);
 	GlooxMessageHandler *p;
-	std::map<std::string,std::string> versions;
+	std::map<int,std::string> versions;
+	int version;
 };
 
 #endif
============================================================
--- discoinfohandler.cpp	e5f47a8984ce6fc03501b74da1496414506525f1
+++ discoinfohandler.cpp	f3a540cb046bb1b41b36a14395f22031ab6409df
@@ -29,19 +29,19 @@ GlooxDiscoInfoHandler::~GlooxDiscoInfoHa
 }
 
 
-bool GlooxDiscoInfoHandler::handleIq (Stanza *stanza){
+bool GlooxDiscoInfoHandler::handleIq (const IQ &stanza){
 
-/*	User *user = p->getUserByJID(stanza->from().bare());
+/*	User *user = p->getUserByJID(stanza.from().bare());
 	if (user==NULL)
 		return true;
 
-	if(stanza->subtype() == StanzaIqGet) {
+	if(stanza.subtype() == IQ::Get) {
 		std::list<std::string> temp;
-		temp.push_back((std::string)stanza->id());
-		temp.push_back((std::string)stanza->from().full());
-		vcardRequests[(std::string)stanza->to().username()]=temp;
+		temp.push_back((std::string)stanza.id());
+		temp.push_back((std::string)stanza.from().full());
+		vcardRequests[(std::string)stanza.to().username()]=temp;
 		
-		serv_get_info(purple_account_get_connection(user->account), stanza->to().username().c_str());
+		serv_get_info(purple_account_get_connection(user->account), stanza.to().username().c_str());
 	}*/
 /*
 <iq from='romeo at montague.lit/orchard' 
@@ -58,15 +58,18 @@ bool GlooxDiscoInfoHandler::handleIq (St
   </query>
 </iq>*/
 
-	std::cout << "DISCO DISCO DISCO " << stanza->xml() << "\n";
-	if(stanza->subtype() == StanzaIqGet && stanza->to().username()!="") {
-		Tag *query = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
+// 	std::cout << "DISCO DISCO DISCO " << stanza.xml() << "\n";
+	if(stanza.subtype() == IQ::Get && stanza.to().username()!="") {
+		Tag *query = stanza.tag()->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
 		if (query!=NULL){
-			Stanza *s = Stanza::createIqStanza(stanza->from(), stanza->id(), StanzaIqResult, "http://jabber.org/protocol/disco#info");
+			IQ _s(IQ::Result, stanza.from(), stanza.id());
+			std::string from;
+			from.append(stanza.to().full());
+			_s.setFrom(from);
+			
+			Tag *s = _s.tag();
+			s->setXmlns("http://jabber.org/protocol/disco#info");
 			s->addAttribute("node",query->findAttribute("node"));
-			std::string from;
-			from.append(stanza->to().full());
-			s->addAttribute("from",from);
 			Tag *t;
 			t = new Tag("identity");
 			t->addAttribute("category","gateway");
@@ -89,7 +92,7 @@ bool GlooxDiscoInfoHandler::handleIq (St
 	return p->j->disco()->handleIq(stanza);
 }
 
-bool GlooxDiscoInfoHandler::handleIqID (Stanza *stanza, int context){
-	return p->j->disco()->handleIqID(stanza,context);
+void GlooxDiscoInfoHandler::handleIqID (const IQ &stanza, int context){
+	p->j->disco()->handleIqID(stanza,context);
 }
 
============================================================
--- discoinfohandler.h	957e8460abbd85e9417f617f13ca0cecc64d79d8
+++ discoinfohandler.h	041af6eb68e6fdc1779beafcc73d96d95f063a8e
@@ -38,8 +38,8 @@ public:
 public:
 	GlooxDiscoInfoHandler(GlooxMessageHandler *parent);
 	~GlooxDiscoInfoHandler();
-	bool handleIq (Stanza *stanza);
-	bool handleIqID (Stanza *stanza, int context);
+	bool handleIq (const IQ &iq);
+	void handleIqID (const IQ &iq, int context);
 	GlooxMessageHandler *p;
 
 };
============================================================
--- filetransfermanager.cpp	6c8f84c803fc11a3eac9b37f0dbb49a4e137ac00
+++ filetransfermanager.cpp	3ef8debce199cd87fb38294930eb21e2ebc104dc
@@ -25,7 +25,7 @@ void FileTransferManager::setSIProfileFT
 	p = parent;
 	mutex = new MyMutex();
 }
-
+/*
 void FileTransferManager::handleFTRequest( const gloox::JID &from,const gloox::JID &to, const std::string &id, const std::string &sid,
                                              const std::string &name, long size, const std::string &hash,
                                              const std::string &date, const std::string &mimetype,
@@ -105,4 +105,4 @@ void FileTransferManager::sendFile(std::
     } else {
         std::cout << "FileTransferManager::sendFile" << " Couldn't open the file " << file << "!\n";
     }
-}
+}*/
============================================================
--- filetransfermanager.h	84d2b79a8bc7ae0dfce80934a383e3a1fbfa32ff
+++ filetransfermanager.h	2642a6f8e59527e873627d9b37a39327adcb136f
@@ -66,14 +66,18 @@ class FileTransferManager : public gloox
 		std::map<std::string, progress> m_progress;
 		void setSIProfileFT(gloox::SIProfileFT *sipft,GlooxMessageHandler *parent);
 
-		void handleFTRequest(   const gloox::JID &from,const gloox::JID &to, const std::string &id, const std::string &sid, const std::string &name,
-                             long size, const std::string &hash, const std::string &date, const std::string &mimetype,
-                             const std::string &desc, int stypes, long offset, long length);
+// 		void handleFTRequest(   const gloox::JID &from,const gloox::JID &to, const std::string &id, const std::string &sid, const std::string &name,
+//                              long size, const std::string &hash, const std::string &date, const std::string &mimetype,
+//                              const std::string &desc, int stypes, long offset, long length);
  
-		void handleFTRequestError(gloox::Stanza *stanza, const std::string &sid);
+// 		void handleFTRequestError(gloox::Stanza *stanza, const std::string &sid);
 
-		void handleFTSOCKS5Bytestream(gloox::SOCKS5Bytestream *s5b);
+// 		void handleFTSOCKS5Bytestream(gloox::SOCKS5Bytestream *s5b);
+		void handleFTRequest (const JID &from, const std::string &sid, const std::string &name, long size, const std::string &hash, const std::string &date, const std::string &mimetype, const std::string &desc, int stypes, long offset, long length) {}
+		void handleFTRequestError (const IQ &iq, const std::string &sid) {}
+		void handleFTBytestream (Bytestream *bs) {}
+		const std::string handleOOBRequestResult (const JID &from, const std::string &sid) { return ""; }
 
-		void sendFile(std::string jid,std::string from,std::string name, std::string file);
+		void sendFile(std::string jid,std::string from,std::string name, std::string file) {}
 	};
 #endif
============================================================
--- gatewayhandler.cpp	e25fee8e97761d6bd05233827ab7d33467fde409
+++ gatewayhandler.cpp	81f8dd1b711d03d39ee5cc5c2a14ffdf6430f2e4
@@ -45,9 +45,9 @@ std::string GlooxGatewayHandler::replace
 	return str;
 }
 
-bool GlooxGatewayHandler::handleIq (Stanza *stanza){
+bool GlooxGatewayHandler::handleIq (const IQ &stanza){
 
-	if(stanza->subtype() == StanzaIqGet) {
+	if(stanza.subtype() == IQ::Get) {
 		//   <iq type='result' from='aim.jabber.org' to='stpeter at jabber.org/roundabout' id='gate1'>
 		//     <query xmlns='jabber:iq:gateway'>
 		//       <desc>
@@ -57,8 +57,10 @@ bool GlooxGatewayHandler::handleIq (Stan
 		//       <prompt>Contact ID</prompt>
 		//     </query>
 		//   </iq>
-		Stanza *s = Stanza::createIqStanza(stanza->from(), stanza->id(), StanzaIqResult, "jabber:iq:gateway");
-		s->addAttribute("from",p->jid());
+		IQ _s(IQ::Result, stanza.from(), stanza.id());
+		_s.setFrom(p->jid());
+		Tag *s = _s.tag();
+		s->setXmlns("jabber:iq:gateway");
 		
 		s->findChild("query")->addChild(new Tag("desc","Please enter the ICQ Number of the person you would like to contact."));
 		s->findChild("query")->addChild(new Tag("prompt","Contact ID"));
@@ -66,8 +68,8 @@ bool GlooxGatewayHandler::handleIq (Stan
 		p->j->send( s );
 		return true;
 	}
-	else if(stanza->subtype() == StanzaIqSet){
-		Tag *query = stanza->findChild("query");
+	else if(stanza.subtype() == IQ::Set){
+		Tag *query = stanza.tag()->findChild("query");
 		if (query==NULL)
 			return false;
 		Tag *prompt = query->findChild("prompt");
@@ -79,8 +81,10 @@ bool GlooxGatewayHandler::handleIq (Stan
 		uin = replace(uin,"-","");
 		uin = replace(uin," ","");
 		
-		Stanza *s = Stanza::createIqStanza(stanza->from(), stanza->id(), StanzaIqResult, "jabber:iq:gateway");
-		s->addAttribute("from",p->jid());
+		IQ _s(IQ::Result, stanza.from(), stanza.id());
+		_s.setFrom(p->jid());
+		Tag *s = _s.tag();
+		s->setXmlns("jabber:iq:gateway");
 		s->findChild("query")->addChild(new Tag("jid",uin+"@"+p->jid()));
 		s->findChild("query")->addChild(new Tag("prompt",uin+"@"+p->jid()));
 		
@@ -91,6 +95,5 @@ bool GlooxGatewayHandler::handleIq (Stan
 	return false;
 }
 
-bool GlooxGatewayHandler::handleIqID (Stanza *stanza, int context){
-	return false;
+void GlooxGatewayHandler::handleIqID (const IQ &iq, int context){
 }
============================================================
--- gatewayhandler.h	e6490586b24de43a00904f2fff593ccfa3c995a5
+++ gatewayhandler.h	4edd3a90613e26fda1e4714cce970812b49c8bf8
@@ -35,8 +35,8 @@ public:
 public:
 	GlooxGatewayHandler(GlooxMessageHandler *parent);
 	~GlooxGatewayHandler();
-	bool handleIq (Stanza *stanza);
-	bool handleIqID (Stanza *stanza, int context);
+	bool handleIq (const IQ &iq);
+	void handleIqID (const IQ &iq, int context);
 	std::string replace(std::string &str, const char *string_to_replace, const char *new_string);
 	GlooxMessageHandler *p;
 };
============================================================
--- main.cpp	b5410dac1aba1aa1d40b24110c05eaaf5c04339f
+++ main.cpp	bc969b37b0ea611f451ec9e9aed65a21fc4b7a1e
@@ -477,7 +477,7 @@ GlooxMessageHandler::GlooxMessageHandler
 	loadProtocol();
 
 	m_discoHandler=new GlooxDiscoHandler(this);
- 	j->removeIqHandler(XMLNS_DISCO_INFO);
+//  	j->removeIqHandler(XMLNS_DISCO_INFO);
 	
  	m_discoInfoHandler=new GlooxDiscoInfoHandler(this);
  	j->registerIqHandler(m_discoInfoHandler,XMLNS_DISCO_INFO);
@@ -563,9 +563,9 @@ void GlooxMessageHandler::purpleConnecti
 		// fatal error => account will be disconnected, so we have to remove it
 		if (reason!=0){
 			if (text){
-				Stanza *s = Stanza::createMessageStanza(user->jid(), (std::string)text);
+				Message s(Message::Chat, user->jid(), (std::string)text);
 				std::string from;
-				s->addAttribute("from",jid());
+				s.setFrom(jid());
 				j->send(s);
 			}
 // 			if (user->isConnected()==true){
@@ -576,9 +576,9 @@ void GlooxMessageHandler::purpleConnecti
 		else{
 			if (user->reconnectCount()==1){
 				if (text){
-					Stanza *s = Stanza::createMessageStanza(user->jid(), (std::string)text);
+					Message s(Message::Chat, user->jid(), (std::string)text);
 					std::string from;
-					s->addAttribute("from",jid());
+					s.setFrom(jid());
 					j->send(s);
 				}
 // 				if (user->isConnected()==true){
@@ -751,13 +751,13 @@ void GlooxMessageHandler::purpleFileRece
 	User *user = userManager()->getUserByAccount(purple_xfer_get_account(xfer));
 	if (user!=NULL){
 		if(user->hasFeature(GLOOX_FEATURE_FILETRANSFER)){
-			Stanza *s = Stanza::createMessageStanza(user->jid(), "Uzivatel vam posila soubor '"+filename+"'. Ihned po doruceni na nas server vam bude preposlan.");
-			s->addAttribute("from",remote_user+"@"+jid()+"/bot");
+			Message s(Message::Chat, user->jid(), "Uzivatel vam posila soubor '"+filename+"'. Ihned po doruceni na nas server vam bude preposlan.");
+			s.setFrom(remote_user+"@"+jid()+"/bot");
 			j->send(s);
 		}
 		else{
-			Stanza *s = Stanza::createMessageStanza(user->jid(), "Uzivatel vam posila soubor '"+filename+"'. Ihned po doruceni na nas server vam bude preposlan odkaz umoznujici stazeni souboru.");
-			s->addAttribute("from",remote_user+"@"+jid()+"/bot");
+			Message s(Message::Chat, user->jid(), "Uzivatel vam posila soubor '"+filename+"'. Ihned po doruceni na nas server vam bude preposlan odkaz umoznujici stazeni souboru.");
+			s.setFrom(remote_user+"@"+jid()+"/bot");
 			j->send(s);
 		}
 	}
@@ -785,8 +785,8 @@ void GlooxMessageHandler::purpleFileRece
 				else {
 					sql()->addDownload(basename,"0");
 				}
-				Stanza *s = Stanza::createMessageStanza(user->jid(), "Soubor '"+filename+"' byl prijat. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
-				s->addAttribute("from",remote_user+"@"+jid()+"/bot");
+				Message s(Message::Chat, user->jid(), "Soubor '"+filename+"' byl prijat. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
+				s.setFrom(remote_user+"@"+jid()+"/bot");
 				j->send(s);
 			}
 			else{
@@ -796,8 +796,8 @@ void GlooxMessageHandler::purpleFileRece
 				else {
 					sql()->addDownload(basename,"0");
 				}
-				Stanza *s = Stanza::createMessageStanza(user->jid(), "Soubor '"+filename+"' byl prijat. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
-				s->addAttribute("from",remote_user+"@"+jid()+"/bot");
+				Message s(Message::Chat, user->jid(), "Soubor '"+filename+"' byl prijat. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
+				s.setFrom(remote_user+"@"+jid()+"/bot");
 				j->send(s);
 			}
 		}
@@ -878,85 +878,90 @@ bool GlooxMessageHandler::hasCaps(const 
 	return false;
 }
 
-void GlooxMessageHandler::handleSubscription(Stanza *stanza) {
-	handlePresence(stanza);
+void GlooxMessageHandler::handleSubscription(const Subscription &stanza) {
+	// answer to subscibe
+	if(stanza.subtype() == Subscription::Subscribe && stanza.to().username() == "") {
+		Log().Get(stanza.from().full()) << "Subscribe presence received => sending subscribed";
+		Tag *reply = new Tag("presence");
+		reply->addAttribute( "to", stanza.from().bare() );
+		reply->addAttribute( "from", stanza.to().bare() );
+		reply->addAttribute( "type", "subscribed" );
+		j->send( reply );
+	}
+	
+	User *user = userManager()->getUserByJID(stanza.from().bare());
+	if (user)
+		user->receivedSubscription(stanza);
+	
 }
 
-void GlooxMessageHandler::handlePresence(Stanza * stanza){
-	if(stanza->subtype() == StanzaPresenceError) {
+void GlooxMessageHandler::handlePresence(const Presence &stanza){
+	if(stanza.subtype() == Presence::Error) {
 		return;
 	}
 	// get entity capabilities
 	Tag *c = NULL;
-	Log().Get(stanza->from().full()) << "Presence received (" << stanza->subtype() << ") for: " << stanza->to().full();
+	Log().Get(stanza.from().full()) << "Presence received (" << stanza.subtype() << ") for: " << stanza.to().full();
 
-	if (stanza->presence() != PresenceUnavailable && stanza->to().username() == ""){
-		Tag *c = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/caps");
+	if (stanza.presence() != Presence::Unavailable && stanza.to().username() == ""){
+		Tag *c = stanza.tag()->findChildWithAttrib("xmlns","http://jabber.org/protocol/caps");
 		// presence has caps
 		if (c!=NULL){
 			// caps is not chached
 			if (!hasCaps(c->findAttribute("ver"))){
 				// ask for caps
 				std::string id = j->getID();
-				Log().Get(stanza->from().full()) << "asking for caps with ID: " << id;
-				m_discoHandler->versions[id]=c->findAttribute("ver");
+				Log().Get(stanza.from().full()) << "asking for caps with ID: " << id;
+				m_discoHandler->versions[m_discoHandler->version]=c->findAttribute("ver");
 				std::string node;
 				node = c->findAttribute("node")+std::string("#")+c->findAttribute("ver");
-				j->disco()->getDiscoInfo(stanza->from(),node,m_discoHandler,0,id);
+				j->disco()->getDiscoInfo(stanza.from(),node,m_discoHandler,m_discoHandler->version,id);
+				m_discoHandler->version++;
 			}
 			else {
 				std::string id = j->getID();
-				Log().Get(stanza->from().full()) << "asking for disco#info with ID: " << id;
-				m_discoHandler->versions[id]=stanza->from().full();
-				j->disco()->getDiscoInfo(stanza->from(),"",m_discoHandler,0,id);
+				Log().Get(stanza.from().full()) << "asking for disco#info with ID: " << id;
+				m_discoHandler->versions[m_discoHandler->version]=stanza.from().full();
+				j->disco()->getDiscoInfo(stanza.from(),"",m_discoHandler,m_discoHandler->version,id);
+				m_discoHandler->version++;
 			}
 		}
 		else {
 			std::string id = j->getID();
-			Log().Get(stanza->from().full()) << "asking for disco#info with ID: " << id;
-			m_discoHandler->versions[id]=stanza->from().full();
-			j->disco()->getDiscoInfo(stanza->from(),"",m_discoHandler,0,id);
+			Log().Get(stanza.from().full()) << "asking for disco#info with ID: " << id;
+			m_discoHandler->versions[m_discoHandler->version]=stanza.from().full();
+			j->disco()->getDiscoInfo(stanza.from(),"",m_discoHandler,m_discoHandler->version,id);
+			m_discoHandler->version++;
 		}
 	}
 
-
-	// answer to subscibe
-	if(stanza->subtype() == StanzaS10nSubscribe && stanza->to().username() == "") {
-		Log().Get(stanza->from().full()) << "Subscribe presence received => sending subscribed";
-		Tag *reply = new Tag("presence");
-		reply->addAttribute( "to", stanza->from().bare() );
-		reply->addAttribute( "from", stanza->to().bare() );
-		reply->addAttribute( "type", "subscribed" );
-		j->send( reply );
-	}
-
-	User *user = userManager()->getUserByJID(stanza->from().bare());
+	User *user = userManager()->getUserByJID(stanza.from().bare());
 	if (user==NULL){
 		// we are not connected and probe arrived => answer with unavailable
-		if (stanza->subtype() == StanzaPresenceProbe){
-			Log().Get(stanza->from().full()) << "Answering to probe presence with unavailable presence";
+		if (stanza.subtype() == Presence::Probe){
+			Log().Get(stanza.from().full()) << "Answering to probe presence with unavailable presence";
 			Tag *tag = new Tag("presence");
-			tag->addAttribute("to",stanza->from().full());
-			tag->addAttribute("from",stanza->to().bare()+"/bot");
+			tag->addAttribute("to",stanza.from().full());
+			tag->addAttribute("from",stanza.to().bare()+"/bot");
 			tag->addAttribute("type","unavailable");
 			j->send(tag);
 		}
-		else if (stanza->to().username() == "" && stanza->presence() != PresenceUnavailable){
-			UserRow res = sql()->getUserByJid(stanza->from().bare());
+		else if (stanza.to().username() == "" && stanza.presence() != Presence::Unavailable){
+			UserRow res = sql()->getUserByJid(stanza.from().bare());
 			if(res.id==-1) {
 				// presence from unregistered user
-				Log().Get(stanza->from().full()) << "This user is not registered";
+				Log().Get(stanza.from().full()) << "This user is not registered";
 				return;
 			}
 			else {
-				bool isVip = sql()->isVIP(stanza->from().bare());
+				bool isVip = sql()->isVIP(stanza.from().bare());
 				if (configuration().onlyForVIP && !isVip){
-					Log().Get(stanza->from().full()) << "This user is not VIP, can't login...";
+					Log().Get(stanza.from().full()) << "This user is not VIP, can't login...";
 					return;
 				}
 
-				Log().Get(stanza->from().full()) << "Creating new User instance";
-				user = new User(this, stanza->from().bare(), res.uin, res.password);
+				Log().Get(stanza.from().full()) << "Creating new User instance";
+				user = new User(this, stanza.from().bare(), res.uin, res.password);
 				if (c!=NULL)
 					if(hasCaps(c->findAttribute("ver")))
 						user->setCapsVersion(c->findAttribute("ver"));
@@ -978,13 +983,13 @@ void GlooxMessageHandler::handlePresence
 // 				user->init(this);
 				m_userManager->addUser(user);
 				user->receivedPresence(stanza);
-				g_timeout_add(15000,&connectUser,g_strdup(stanza->from().bare().c_str()));
+				g_timeout_add(15000,&connectUser,g_strdup(stanza.from().bare().c_str()));
 			}
 		}
-		if (stanza->presence() == PresenceUnavailable && stanza->to().username() == ""){
-			Log().Get(stanza->from().full()) << "User is already logged out => sending unavailable presence";
+		if (stanza.presence() == Presence::Unavailable && stanza.to().username() == ""){
+			Log().Get(stanza.from().full()) << "User is already logged out => sending unavailable presence";
 			Tag *tag = new Tag("presence");
-			tag->addAttribute( "to", stanza->from().bare() );
+			tag->addAttribute( "to", stanza.from().bare() );
 			tag->addAttribute( "type", "unavailable" );
 			tag->addAttribute( "from", jid() );
 			j->send( tag );
@@ -993,17 +998,17 @@ void GlooxMessageHandler::handlePresence
 	else{
 		user->receivedPresence(stanza);
 	}
-	if(stanza->to().username() == "" && user!=NULL){
-		if(stanza->presence() == PresenceUnavailable && user->isConnected()==true && user->resources().empty()) {
-			Log().Get(stanza->from().full()) << "Logging out";
+	if(stanza.to().username() == "" && user!=NULL){
+		if(stanza.presence() == Presence::Unavailable && user->isConnected()==true && user->resources().empty()) {
+			Log().Get(stanza.from().full()) << "Logging out";
 			m_userManager->removeUser(user);
 		}
-		else if (stanza->presence() == PresenceUnavailable && user->isConnected()==false && int(time(NULL))>int(user->connectionStart())+10 && user->resources().empty()){
-			Log().Get(stanza->from().full()) << "Logging out, but he's not connected...";
+		else if (stanza.presence() == Presence::Unavailable && user->isConnected()==false && int(time(NULL))>int(user->connectionStart())+10 && user->resources().empty()){
+			Log().Get(stanza.from().full()) << "Logging out, but he's not connected...";
 			m_userManager->removeUser(user);
 		}
-		else if (stanza->presence() == PresenceUnavailable && user->isConnected()==false){
-			Log().Get(stanza->from().full()) << "Can't logout because we're connecting now...";
+		else if (stanza.presence() == Presence::Unavailable && user->isConnected()==false){
+			Log().Get(stanza.from().full()) << "Can't logout because we're connecting now...";
 		}
 	}
     
@@ -1039,22 +1044,21 @@ bool GlooxMessageHandler::onTLSConnect(c
 	return false;
 }
 
-void GlooxMessageHandler::handleMessage( Stanza* stanza, MessageSession* session = 0 ){
-	User *user = userManager()->getUserByJID(stanza->from().bare());
-	Log().Get("purple") << stanza->xml();
+void GlooxMessageHandler::handleMessage (const Message &msg, MessageSession *session) {
+	User *user = userManager()->getUserByJID(msg.from().bare());
 	if (user!=NULL){
 		if (user->isConnected()){
-			Tag *chatstates = stanza->findChildWithAttrib("xmlns","http://jabber.org/protocol/chatstates");
+			Tag *chatstates = msg.tag()->findChildWithAttrib("xmlns","http://jabber.org/protocol/chatstates");
 			if (chatstates!=NULL){
-				user->receivedChatState(stanza->to().username(),chatstates->name());
+				user->receivedChatState(msg.to().username(),chatstates->name());
 			}
-			if(stanza->findChild("body")!=NULL) {
+			if(msg.tag()->findChild("body")!=NULL) {
 				m_stats->messageFromJabber();
-				user->receivedMessage(stanza);
+				user->receivedMessage(msg);
 			}
 			else {
 				// handle activity; TODO: move me to another function or better file
-				Tag *event = stanza->findChild("event");
+				Tag *event = msg.tag()->findChild("event");
 				if (!event) return;
 				Tag *items = event->findChildWithAttrib("node","http://jabber.org/protocol/activity");
 				if (!items) return;
@@ -1093,11 +1097,11 @@ void GlooxMessageHandler::handleMessage(
 			}
 		}
 		else{
-			Log().Get(stanza->from().bare()) << "New message received, but we're not connected yet";
+			Log().Get(msg.from().bare()) << "New message received, but we're not connected yet";
 		}
 	}
 	else{
-		Log().Get(stanza->from().bare()) << "New message received, but we're not connected to legacy network";
+		Log().Get(msg.from().bare()) << "New message received, but we're not connected to legacy network";
 	}
 
 }
============================================================
--- main.h	d60fae49e93f031cade3095d2401c9a210ce8ad3
+++ main.h	cf903376b5aafefc4e4aa6a11bc65d7819574dc8
@@ -36,6 +36,7 @@
 #include <gloox/subscriptionhandler.h>
 #include <gloox/socks5bytestreamserver.h>
 #include <gloox/siprofileft.h>
+#include <gloox/message.h>
 
 #include <glib.h>
 
@@ -151,7 +152,7 @@ public:
 	void purpleFileReceiveComplete(PurpleXfer *xfer);
 
 	// MessageHandler
-	void handleMessage( Stanza* stanza,MessageSession* session);
+	void handleMessage (const Message &msg, MessageSession *session=0);
 
 	// ConnectionListener
 	void onConnect();
@@ -160,8 +161,8 @@ public:
 	bool onTLSConnect(const CertInfo & info);
 	
 	// Gloox handlers
-	void handlePresence(Stanza * stanza);
-	void handleSubscription(Stanza * stanza);
+	void handlePresence(const Presence &presence);
+	void handleSubscription(const Subscription &stanza);
 	void signedOn(PurpleConnection *gc,gpointer unused);
 	
 	// User related
============================================================
--- receivefile.cpp	4b2b3783537a315f29a847cf15b5655bda3d2560
+++ receivefile.cpp	0a4c37f5e23e9531b2e3b55eef5bab39748f6c8d
@@ -48,8 +48,8 @@ static gboolean transferFinished(gpointe
 							else {
 								user->p->sql()->addDownload(basename,"0");
 							}
-							Stanza *s = Stanza::createMessageStanza((*u).second.from.bare(), "Uzivatel Vam poslal soubor '"+basename+"'. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
-							s->addAttribute("from",user->jid());
+							Message s(Message::Chat, (*u).second.from.bare(), "Uzivatel Vam poslal soubor '"+basename+"'. Muzete jej stahnout z adresy http://soumar.jabbim.cz/icq/" + basename +" .");
+							s.setFrom(user->jid());
 							user->receivedMessage(s);
 						}
 					}
@@ -71,7 +71,7 @@ ReceiveFile::ReceiveFile(gloox::SOCKS5By
     m_stream = stream;
     m_size = size;
     m_filename = filename;
-    m_stream->registerSOCKS5BytestreamDataHandler(this);
+//     m_stream->registerSOCKS5BytestreamDataHandler(this);
     m_finished = false;
 	m_mutex = mutex;
 	m_parent = manager;
@@ -113,7 +113,7 @@ void ReceiveFile::handleSOCKS5Error(gloo
 
 void ReceiveFile::handleSOCKS5Error(gloox::SOCKS5Bytestream *s5b, gloox::Stanza *stanza) {
 	Log().Get(m_filename) << "STREAM ERROR!";
-	Log().Get(m_filename) << stanza->xml();
+// 	Log().Get(m_filename) << stanza->xml();
 }
 
 void ReceiveFile::handleSOCKS5Open(gloox::SOCKS5Bytestream *s5b) {
============================================================
--- registerhandler.cpp	890b9981c95dbb9c402f46441f1bc84f7c898d03
+++ registerhandler.cpp	be8865233d27819de97faa1e9afee2ceeb38f954
@@ -34,26 +34,26 @@ GlooxRegisterHandler::~GlooxRegisterHand
 GlooxRegisterHandler::~GlooxRegisterHandler(){
 }
 
-bool GlooxRegisterHandler::handleIq (Stanza *stanza){
-	std::cout << "*** "<< stanza->from().full() << ": iq:register received (" << stanza->subtype() << ")\n";
-	User *user = p->userManager()->getUserByJID(stanza->from().bare());
+bool GlooxRegisterHandler::handleIq (const IQ &iq){
+	std::cout << "*** "<< iq.from().full() << ": iq:register received (" << iq.subtype() << ")\n";
+	User *user = p->userManager()->getUserByJID(iq.from().bare());
 	if (p->configuration().onlyForVIP){
-		bool isVIP = p->sql()->isVIP(stanza->from().bare());
+		bool isVIP = p->sql()->isVIP(iq.from().bare());
 		if (!isVIP)
 			return false;
 	}
 	
 	
 	// send registration form
-	if(stanza->subtype() == StanzaIqGet) {
+	if(iq.subtype() == IQ::Get) {
 		Tag *reply = new Tag( "iq" );
-		reply->addAttribute( "id", stanza->id() );
+		reply->addAttribute( "id", iq.id() );
 		reply->addAttribute( "type", "result" );
-		reply->addAttribute( "to", stanza->from().full() );
+		reply->addAttribute( "to", iq.from().full() );
 		reply->addAttribute( "from", p->jid() );
 		Tag *query = new Tag( "query" );
 		query->addAttribute( "xmlns", "jabber:iq:register" );
-		UserRow res = p->sql()->getUserByJid(stanza->from().bare());
+		UserRow res = p->sql()->getUserByJid(iq.from().bare());
 		if(res.id==-1) {
 			std::cout << "* sending registration form; user is not registered\n";
 			query->addChild( new Tag("instructions", p->protocol()->text("instructions")) );
@@ -72,9 +72,9 @@ bool GlooxRegisterHandler::handleIq (Sta
 		p->j->send( reply );
 		return true;
 	}
-	else if(stanza->subtype() == StanzaIqSet) {
+	else if(iq.subtype() == IQ::Set) {
 		bool sendsubscribe = false;
-		Tag *query = stanza->findChild( "query" );
+		Tag *query = iq.tag()->findChild( "query" );
 
 		if (!query) return true;
 
@@ -92,7 +92,7 @@ bool GlooxRegisterHandler::handleIq (Sta
 			if (true){
 				std::cout << "* sending rosterX\n";
 				Tag *tag = new Tag("message");
-				tag->addAttribute( "to", stanza->from().bare() );
+				tag->addAttribute( "to", iq.from().bare() );
 				std::string from;
 				from.append(p->jid());
 				tag->addAttribute( "from", from );
@@ -102,7 +102,7 @@ bool GlooxRegisterHandler::handleIq (Sta
 				Tag *item;
 
 				std::map<std::string,RosterRow> roster;
-				roster = p->sql()->getRosterByJid(stanza->from().bare());
+				roster = p->sql()->getRosterByJid(iq.from().bare());
 				// add users which are added to roster
 				for(std::map<std::string, RosterRow>::iterator u = roster.begin(); u != roster.end() ; u++){
 					if (!(*u).second.uin.empty()){
@@ -116,8 +116,8 @@ bool GlooxRegisterHandler::handleIq (Sta
 				tag->addChild(x);
 				std::cout << "* sending " << tag->xml() << "\n";
 				p->j->send(tag);
-				p->sql()->removeUser(stanza->from().bare());
-				p->sql()->removeUserFromRoster(stanza->from().bare());
+				p->sql()->removeUser(iq.from().bare());
+				p->sql()->removeUserFromRoster(iq.from().bare());
 
 			}
 			else{
@@ -136,19 +136,19 @@ bool GlooxRegisterHandler::handleIq (Sta
 			Tag *reply = new Tag("iq");
 			reply->addAttribute( "type", "result" );
 			reply->addAttribute( "from", p->jid() );
-			reply->addAttribute( "to", stanza->from().full() );
-			reply->addAttribute( "id", stanza->id() );
+			reply->addAttribute( "to", iq.from().full() );
+			reply->addAttribute( "id", iq.id() );
 			p->j->send( reply );
 
 			reply = new Tag( "presence" );
 			reply->addAttribute( "type", "unsubscribe" );
 			reply->addAttribute( "from", p->jid() );
-			reply->addAttribute( "to", stanza->from().full() );
+			reply->addAttribute( "to", iq.from().full() );
 			p->j->send( reply );
 
 			reply = new Tag("presence");
 			reply->addAttribute( "type", "unsubscribed" );
-			reply->addAttribute( "to", stanza->from().full() );
+			reply->addAttribute( "to", iq.from().full() );
 			reply->addAttribute( "from", p->jid() );
 			p->j->send( reply );
 			return true;
@@ -156,7 +156,7 @@ bool GlooxRegisterHandler::handleIq (Sta
 	
 		// Register or change password
 	
-		std::string jid = stanza->from().bare();
+		std::string jid = iq.from().bare();
 		Tag *usernametag = query->findChild("username");
 		Tag *passwordtag = query->findChild("password");
 		std::string username("");
@@ -182,11 +182,11 @@ bool GlooxRegisterHandler::handleIq (Sta
 //	</error>
 //    </iq>
 		if (e) {
-		    Tag *iq = new Tag("iq");
-		    iq->addAttribute("type","error");
-		    iq->addAttribute("from", p->jid());
-		    iq->addAttribute("to", stanza->from().full());
-		    iq->addAttribute("id", stanza->id());
+		    Tag *iq2 = new Tag("iq");
+		    iq2->addAttribute("type","error");
+		    iq2->addAttribute("from", p->jid());
+		    iq2->addAttribute("to", iq.from().full());
+		    iq2->addAttribute("id", iq.id());
 		    
 			Tag *error = new Tag("error");
 		    error->addAttribute("code",400);
@@ -195,16 +195,16 @@ bool GlooxRegisterHandler::handleIq (Sta
 		    bad->addAttribute("xmlns","urn:ietf:params:xml:ns:xmpp-stanzas");
 		    
 		    error->addChild(bad);
-		    iq->addChild(error);
+		    iq2->addChild(error);
 		    
-		    p->j->send(iq);
+		    p->j->send(iq2);
 		    
 		    return true;
 		}
 
 
 
-		UserRow res = p->sql()->getUserByJid(stanza->from().bare());
+		UserRow res = p->sql()->getUserByJid(iq.from().bare());
 		if(res.id==-1) {
 	
 // 			if(false) {
@@ -227,12 +227,12 @@ bool GlooxRegisterHandler::handleIq (Sta
 		} else {
 			// change password
 			std::cout << "* changing user password: "<< jid << ", " << username << ", " << password <<"\n";
-			p->sql()->updateUserPassword(stanza->from().bare(),password);
+			p->sql()->updateUserPassword(iq.from().bare(),password);
 		}
 		Tag *reply = new Tag( "iq" );
-		reply->addAttribute( "id", stanza->id() );
+		reply->addAttribute( "id", iq.id() );
 		reply->addAttribute( "type", "result" );
-		reply->addAttribute( "to", stanza->from().full() );
+		reply->addAttribute( "to", iq.from().full() );
 		reply->addAttribute( "from", p->jid() );
 		Tag *rquery = new Tag( "query" );
 		rquery->addAttribute( "xmlns", "jabber:iq:register" );
@@ -242,7 +242,7 @@ bool GlooxRegisterHandler::handleIq (Sta
 		if(sendsubscribe) {
 		reply = new Tag("presence");
 		reply->addAttribute( "from", p->jid() );
-		reply->addAttribute( "to", stanza->from().bare() );
+		reply->addAttribute( "to", iq.from().bare() );
 		reply->addAttribute( "type", "subscribe" );
 		p->j->send( reply );
 		}
@@ -251,7 +251,6 @@ bool GlooxRegisterHandler::handleIq (Sta
 	return false;
 }
 
-bool GlooxRegisterHandler::handleIqID (Stanza *stanza, int context){
+void GlooxRegisterHandler::handleIqID (const IQ &iq, int context){
 	std::cout << "IQ ID IQ ID IQ ID\n";
-	return true;
 }
============================================================
--- registerhandler.h	1e2aede0f4882476596420ba2c272fa58f96da56
+++ registerhandler.h	d40c34f92f1a99111fdae46f9c9488dd6af21bc8
@@ -37,8 +37,8 @@ public:
 public:
 	GlooxRegisterHandler(GlooxMessageHandler *parent);
 	~GlooxRegisterHandler();
-	bool handleIq (Stanza *stanza);
-	bool handleIqID (Stanza *stanza, int context);
+	bool handleIq (const IQ &iq);
+	void handleIqID (const IQ &iq, int context);
 	
 	GlooxMessageHandler *p;
 };
============================================================
--- sendfile.cpp	ff5a9f9086c57be7d58c206fa40a72b381e4fb74
+++ sendfile.cpp	a8df3e38ada722ba777e6e155db8998bf90ac747
@@ -25,7 +25,7 @@ SendFile::SendFile(gloox::SOCKS5Bytestre
     m_stream = stream;
     m_filename = filename;
     m_size = size;
-    m_stream->registerSOCKS5BytestreamDataHandler(this);
+//     m_stream->registerSOCKS5BytestreamDataHandler(this);
 	m_mutex = mutex;
 	m_parent = manager;
 	if (m_stream->connect())
============================================================
--- statshandler.cpp	7c3bc387f2179ee448fbfe7511150a224ddd8e97
+++ statshandler.cpp	fa01863ecf8e59a4812115d0885748b56e75663b
@@ -38,7 +38,7 @@ GlooxStatsHandler::~GlooxStatsHandler(){
 GlooxStatsHandler::~GlooxStatsHandler(){
 }
 
-bool GlooxStatsHandler::handleIq (Stanza *stanza){
+bool GlooxStatsHandler::handleIq (const IQ &stanza){
 // 	      recv:     <iq type='result' from='component'>
 //                   <query xmlns='http://jabber.org/protocol/stats'>
 // 	            <stat name='time/uptime'/>
@@ -52,17 +52,20 @@ bool GlooxStatsHandler::handleIq (Stanza
 //                 </iq>
 //       
 
-	Tag *query = stanza->findChild("query");
+	Tag *query = stanza.tag()->findChild("query");
 	if (query==NULL)
 		return true;
-	std::cout << "*** "<< stanza->from().full() << ": received stats request\n";
+	std::cout << "*** "<< stanza.from().full() << ": received stats request\n";
 	std::list<Tag*> stats = query->children();
 	if (stats.empty()){
 		std::cout << "* sending stats keys\n";
-		Stanza *s = Stanza::createIqStanza(stanza->from(), stanza->id(), StanzaIqResult, "http://jabber.org/protocol/stats");
+		IQ _s(IQ::Result, stanza.from(), stanza.id());
 		std::string from;
 		from.append(p->jid());
-		s->addAttribute("from",from);
+		_s.setFrom(from);
+
+		Tag *s = _s.tag();
+		s->setXmlns("http://jabber.org/protocol/stats");
 		Tag *t;
 
 		t = new Tag("stat");
@@ -98,10 +101,13 @@ bool GlooxStatsHandler::handleIq (Stanza
 	}
 	else{
 		std::cout << "* sending stats values\n";
-		Stanza *s = Stanza::createIqStanza(stanza->from(), stanza->id(), StanzaIqResult, "http://jabber.org/protocol/stats");
+		IQ _s(IQ::Result, stanza.from(), stanza.id());
 		std::string from;
 		from.append(p->jid());
-		s->addAttribute("from",from);
+		_s.setFrom(from);
+
+		Tag *s = _s.tag();
+		s->setXmlns("http://jabber.org/protocol/stats");
 		Tag *t;
 		long registered = p->sql()->getRegisteredUsersCount();
 		long registeredUsers = p->sql()->getRegisteredUsersRosterCount();
@@ -164,6 +170,5 @@ bool GlooxStatsHandler::handleIq (Stanza
 	return true;
 }
 
-bool GlooxStatsHandler::handleIqID (Stanza *stanza, int context){
-	return false;
+void GlooxStatsHandler::handleIqID (const IQ &iq, int context){
 }
============================================================
--- statshandler.h	5521ba5274cf505114dfa3b0878254ed222c04bd
+++ statshandler.h	4ee6ac32e70e19f65fb01a93224c240c0be51025
@@ -35,8 +35,8 @@ class GlooxStatsHandler : public IqHandl
 	public:
 		GlooxStatsHandler(GlooxMessageHandler *parent);
 		~GlooxStatsHandler();
-		bool handleIq (Stanza *stanza);
-		bool handleIqID (Stanza *stanza, int context);
+		bool handleIq (const IQ &iq);
+		void handleIqID (const IQ &iq, int context);
 		GlooxMessageHandler *p;
 	
 		void messageFromLegacy() { m_messagesOut++; }
============================================================
--- user.cpp	ab26ce5358c92fa6bd8f88ce91cd85d9763142e2
+++ user.cpp	4814e7b089407c3b6ab9cd507f3c1169ad6f1049
@@ -23,6 +23,7 @@
 #include "log.h"
 #include "protocols/abstractprotocol.h"
 #include "usermanager.h"
+#include "gloox/chatstate.h"
 
 /*
  * Called when contact list has been received from legacy network.
@@ -475,18 +476,17 @@ void User::purpleConversationWriteIM(Pur
 
 	// send message to user
 	std::string message(purple_unescape_html(msg));
-	Stanza *s = Stanza::createMessageStanza(m_jid, message);
+	Message s(Message::Chat, m_jid, message);
 	std::string from;
 	from.append(name);
 	from.append("@");
 	from.append(p->jid() + "/bot");
-	s->addAttribute("from",from);
+	s.setFrom(from);
 
 	// chatstates
 	if (hasFeature(GLOOX_FEATURE_CHATSTATES)) {
-		Tag *active = new Tag("active");
-		active->addAttribute("xmlns","http://jabber.org/protocol/chatstates");
-		s->addChild(active);
+		ChatState *c = new ChatState(ChatStateActive);
+		s.addExtension(c);
 	}
 	
 	// Delayed messages, we have to count with some delay
@@ -494,10 +494,8 @@ void User::purpleConversationWriteIM(Pur
 		char buf[80];
 		strftime(buf, sizeof(buf), "%Y%m%dT%H:%M:%S", localtime(&mtime));
 		std::string timestamp(buf);
-		Tag *delay = new Tag("delay");
-		delay->addAttribute("xmlns","urn:xmpp:delay");
-		delay->addAttribute("stamp",timestamp);
-		s->addChild(delay);
+		DelayedDelivery *d = new DelayedDelivery(from, timestamp);
+		s.addExtension(d);
 	}
 
 	p->j->send( s );
@@ -575,19 +573,19 @@ void User::receivedChatState(const std::
 /*
  * Received new message from jabber user.
  */
-void User::receivedMessage( Stanza* stanza){
+void User::receivedMessage(const Message& msg){
 	PurpleConversation * conv;
 	// open new conversation or get the opened one
-	if (!isOpenedConversation(stanza->to().username())){
-		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,m_account,stanza->to().username().c_str());
-		m_conversations[stanza->to().username()]=conv;
+	if (!isOpenedConversation(msg.to().username())){
+		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,m_account,msg.to().username().c_str());
+		m_conversations[msg.to().username()]=conv;
 	}
 	else{
-		conv = m_conversations[stanza->to().username()];
+		conv = m_conversations[msg.to().username()];
 	}
 	// send this message
 	PurpleConvIm *im = purple_conversation_get_im_data(conv);
-	purple_conv_im_send(im,stanza->body().c_str());
+	purple_conv_im_send(im,msg.body().c_str());
 }
 
 /*
@@ -662,65 +660,39 @@ void User::connected() {
 	m_reconnectCount = 0;
 }
 
-/*
- * Received jabber presence...
- */
-void User::receivedPresence(Stanza *stanza){
-	// we're connected
+void User::receivedSubscription(const Subscription &subscription) {
 	if (m_connected){
-	
-		// respond to probe presence
-		if (stanza->subtype() == StanzaPresenceProbe && stanza->to().username()!=""){
-			PurpleBuddy *buddy = purple_find_buddy(m_account, stanza->to().username().c_str());
-			if (buddy){
-				Tag *probe = generatePresenceStanza(buddy);
-				if (probe){
-					probe->addAttribute( "to", stanza->from().full() );
-					p->j->send(probe);
-				}
-			}
-// 				purpleBuddyChanged(buddy);
-			else{
-				Log().Get(m_jid) << "answering to probe presence with unavailable presence";
-				Tag *tag = new Tag("presence");
-				tag->addAttribute("to",stanza->from().full());
-				tag->addAttribute("from",stanza->to().bare()+"/bot");
-				tag->addAttribute("type","unavailable");
-				p->j->send(tag);
-			}
-		}
-	
-		if(stanza->subtype() == StanzaS10nSubscribed) {
+		if(subscription.subtype() == Subscription::Subscribed) {
 			// we've already received auth request from legacy server, so we should respond to this request
-			if (hasAuthRequest((std::string)stanza->to().username())){
+			if (hasAuthRequest((std::string)subscription.to().username())){
 				Log().Get(m_jid) <<  "subscribed presence for authRequest arrived => accepting the request";
-				m_authRequests[(std::string)stanza->to().username()].authorize_cb(m_authRequests[(std::string)stanza->to().username()].user_data);
-				m_authRequests.erase(stanza->to().username());
+				m_authRequests[(std::string)subscription.to().username()].authorize_cb(m_authRequests[(std::string)subscription.to().username()].user_data);
+				m_authRequests.erase(subscription.to().username());
 			}
 			// subscribed user is not in roster, so we must add him/her there.
-			PurpleBuddy *buddy = purple_find_buddy(m_account, stanza->to().username().c_str());
-			if(!isInRoster(stanza->to().username(),"both")) {
+			PurpleBuddy *buddy = purple_find_buddy(m_account, subscription.to().username().c_str());
+			if(!isInRoster(subscription.to().username(),"both")) {
 				if(!buddy) {
 					Log().Get(m_jid) << "user is not in legacy network contact lists => nothing to be subscribed";
 					// this user is not in ICQ contact list... It's nothing to do here,
 					// because there is no user to authorize
 				} else {
 					Log().Get(m_jid) << "adding this user to local roster and sending presence";
-					if (!isInRoster(stanza->to().username(),"ask")){
+					if (!isInRoster(subscription.to().username(),"ask")){
 						// add user to mysql database and to local cache
 						RosterRow user;
 						user.id=-1;
 						user.jid=m_jid;
-						user.uin=stanza->to().username();
+						user.uin=subscription.to().username();
 						user.subscription="both";
 						user.online=false;
 						user.lastPresence="";
-						m_roster[stanza->to().username()]=user;
-						p->sql()->addUserToRoster(m_jid,(std::string)stanza->to().username(),"both");
+						m_roster[subscription.to().username()]=user;
+						p->sql()->addUserToRoster(m_jid,(std::string)subscription.to().username(),"both");
 					}
 					else{
-						m_roster[stanza->to().username()].subscription="both";
-						p->sql()->updateUserRosterSubscription(m_jid,(std::string)stanza->to().username(),"both");
+						m_roster[subscription.to().username()].subscription="both";
+						p->sql()->updateUserRosterSubscription(m_jid,(std::string)subscription.to().username(),"both");
 					}
 					// user is in ICQ contact list so we can inform jabber user
 					// about status
@@ -733,16 +705,16 @@ void User::receivedPresence(Stanza *stan
 			}
 			return;
 		}
-		else if(stanza->subtype() == StanzaS10nSubscribe) {
-			PurpleBuddy *b = purple_find_buddy(m_account, stanza->to().username().c_str());
+		else if(subscription.subtype() == Subscription::Subscribe) {
+			PurpleBuddy *b = purple_find_buddy(m_account, subscription.to().username().c_str());
 			if (b){
 				purpleReauthorizeBuddy(b);
 			}
-			if(isInRoster(stanza->to().username(),"")) {
-				if (m_roster[stanza->to().username()].subscription=="ask") {
+			if(isInRoster(subscription.to().username(),"")) {
+				if (m_roster[subscription.to().username()].subscription=="ask") {
 					Tag *reply = new Tag("presence");
-					reply->addAttribute( "to", stanza->from().bare() );
-					reply->addAttribute( "from", stanza->to().bare() );
+					reply->addAttribute( "to", subscription.from().bare() );
+					reply->addAttribute( "from", subscription.to().bare() );
 					reply->addAttribute( "type", "subscribe" );
 					p->j->send( reply );
 				}
@@ -750,8 +722,8 @@ void User::receivedPresence(Stanza *stan
 				// username is in local roster (he/her is in ICQ roster too),
 				// so we should send subscribed presence
 				Tag *reply = new Tag("presence");
-				reply->addAttribute( "to", stanza->from().bare() );
-				reply->addAttribute( "from", stanza->to().bare() );
+				reply->addAttribute( "to", subscription.from().bare() );
+				reply->addAttribute( "from", subscription.to().bare() );
 				reply->addAttribute( "type", "subscribed" );
 				p->j->send( reply );
 			}
@@ -759,42 +731,42 @@ void User::receivedPresence(Stanza *stan
 				Log().Get(m_jid) << "subscribe presence; user is not in roster => adding to legacy network";
 				// this user is not in local roster, so we have to send add_buddy request
 				// to our legacy network and wait for response
-				PurpleBuddy *buddy = purple_buddy_new(m_account,stanza->to().username().c_str(),stanza->to().username().c_str());
+				PurpleBuddy *buddy = purple_buddy_new(m_account,subscription.to().username().c_str(),subscription.to().username().c_str());
 				purple_blist_add_buddy(buddy, NULL, NULL ,NULL);
 				purple_account_add_buddy(m_account, buddy);
 			}
 			return;
-		} else if(stanza->subtype() == StanzaS10nUnsubscribe || stanza->subtype() == StanzaS10nUnsubscribed) {
-			PurpleBuddy *buddy = purple_find_buddy(m_account, stanza->to().username().c_str());
-			if(stanza->subtype() == StanzaS10nUnsubscribed) {
+		} else if(subscription.subtype() == Subscription::Unsubscribe || subscription.subtype() == Subscription::Unsubscribed) {
+			PurpleBuddy *buddy = purple_find_buddy(m_account, subscription.to().username().c_str());
+			if(subscription.subtype() == Subscription::Unsubscribed) {
 				// user respond to auth request from legacy network and deny it
-				if (hasAuthRequest((std::string)stanza->to().username())){
+				if (hasAuthRequest((std::string)subscription.to().username())){
 					Log().Get(m_jid) << "unsubscribed presence for authRequest arrived => rejecting the request";
-					m_authRequests[(std::string)stanza->to().username()].deny_cb(m_authRequests[(std::string)stanza->to().username()].user_data);
-					m_authRequests.erase(stanza->to().username());
+					m_authRequests[(std::string)subscription.to().username()].deny_cb(m_authRequests[(std::string)subscription.to().username()].user_data);
+					m_authRequests.erase(subscription.to().username());
 					return;
 				}
 			}
-			if(buddy && isInRoster(stanza->to().username(),"both")) {
+			if(buddy && isInRoster(subscription.to().username(),"both")) {
 				Log().Get(m_jid) << "unsubscribed presence => removing this contact from legacy network";
 				// thi contact is in ICQ contact list, so we can remove him/her
 				purple_account_remove_buddy(m_account,buddy,purple_buddy_get_group(buddy));
 				purple_blist_remove_buddy(buddy);
-// 				purple_privacy_permit_remove(m_account, stanza->to().username().c_str(),false);
+// 				purple_privacy_permit_remove(m_account, subscription.to().username().c_str(),false);
 			} else {
 				// this contact is not in ICQ contact list, so there is nothing to remove...
 			}
-			if(isInRoster(stanza->to().username(),"both")) {
+			if(isInRoster(subscription.to().username(),"both")) {
 				// this contact is in our local roster, so we have to remove her/him
 				Log().Get(m_jid) << "removing this contact from local roster";
-				m_roster.erase(stanza->to().username());
-				p->sql()->removeUINFromRoster(m_jid,stanza->to().username());
+				m_roster.erase(subscription.to().username());
+				p->sql()->removeUINFromRoster(m_jid,subscription.to().username());
 			}
 			// inform user about removing this contact
 			Tag *tag = new Tag("presence");
-			tag->addAttribute( "to", stanza->from().bare() );
-			tag->addAttribute( "from", stanza->to().username() + "@" + p->jid()+"/bot" );
-			if(stanza->subtype() == StanzaS10nUnsubscribe) {
+			tag->addAttribute( "to", subscription.from().bare() );
+			tag->addAttribute( "from", subscription.to().username() + "@" + p->jid()+"/bot" );
+			if(subscription.subtype() == Subscription::Unsubscribe) {
 				tag->addAttribute( "type", "unsubscribe" );
 			} else {
 				tag->addAttribute( "type", "unsubscribed" );
@@ -803,16 +775,46 @@ void User::receivedPresence(Stanza *stan
 			return;
 		}
 	}
+}
 
+/*
+ * Received jabber presence...
+ */
+void User::receivedPresence(const Presence &stanza){
+	// we're connected
+	if (m_connected){
+	
+		// respond to probe presence
+		if (stanza.subtype() == Presence::Probe && stanza.to().username()!=""){
+			PurpleBuddy *buddy = purple_find_buddy(m_account, stanza.to().username().c_str());
+			if (buddy){
+				Tag *probe = generatePresenceStanza(buddy);
+				if (probe){
+					probe->addAttribute( "to", stanza.from().full() );
+					p->j->send(probe);
+				}
+			}
+// 				purpleBuddyChanged(buddy);
+			else{
+				Log().Get(m_jid) << "answering to probe presence with unavailable presence";
+				Tag *tag = new Tag("presence");
+				tag->addAttribute("to",stanza.from().full());
+				tag->addAttribute("from",stanza.to().bare()+"/bot");
+				tag->addAttribute("type","unavailable");
+				p->j->send(tag);
+			}
+		}
+	}
+
 	// this presence is for the transport
-	if(stanza->to().username() == ""){
-		if(stanza->presence() == PresenceUnavailable) {
+	if(stanza.to().username() == ""){
+		if(stanza.presence() == Presence::Unavailable) {
 			// disconnect from legacy network if we are connected
 			std::map<std::string,int> ::iterator iter = m_resources.begin();
 			if ((m_connected==false && int(time(NULL))>int(m_connectionStart)+10) || m_connected==true){
-				iter = m_resources.find(stanza->from().resource());
+				iter = m_resources.find(stanza.from().resource());
 				if(iter != m_resources.end()){
-					m_resources.erase(stanza->from().resource());
+					m_resources.erase(stanza.from().resource());
 				}
 			}
 			if (m_connected){
@@ -837,12 +839,12 @@ void User::receivedPresence(Stanza *stan
 					purple_account_disconnect(m_account);
 				}
 			}
-		} else if(stanza->subtype() == StanzaPresenceAvailable) {
-			m_resource=stanza->from().resource();
+		} else if(stanza.subtype() == Presence::Available) {
+			m_resource=stanza.from().resource();
 			std::map<std::string,int> ::iterator iter = m_resources.begin();
 			iter = m_resources.find(m_resource);
 			if(iter == m_resources.end()){
-				m_resources[m_resource]=stanza->priority();
+				m_resources[m_resource]=stanza.priority();
 			}
 
 			Log().Get(m_jid) << "resource: " << m_resource;
@@ -867,24 +869,24 @@ void User::receivedPresence(Stanza *stan
 				std::string statusMessage;
 				
 				// mirror presence types
-				switch(stanza->presence()) {
-					case PresenceAvailable: {
+				switch(stanza.presence()) {
+					case Presence::Available: {
 						PurplePresenceType=PURPLE_STATUS_AVAILABLE;
 						break;
 					}
-					case PresenceChat: {
+					case Presence::Chat: {
 						PurplePresenceType=PURPLE_STATUS_AVAILABLE;
 						break;
 					}
-					case PresenceAway: {
+					case Presence::Away: {
 						PurplePresenceType=PURPLE_STATUS_AWAY;
 						break;
 					}
-					case PresenceDnd: {
+					case Presence::DND: {
 						PurplePresenceType=PURPLE_STATUS_UNAVAILABLE;
 						break;
 					}
-					case PresenceXa: {
+					case Presence::XA: {
 						PurplePresenceType=PURPLE_STATUS_EXTENDED_AWAY;
 						break;
 					}
@@ -899,7 +901,7 @@ void User::receivedPresence(Stanza *stan
                     statusMessage.append(" - ");
 				}
 
-				statusMessage.append(stanza->status());
+				statusMessage.append(stanza.status());
 
 				if (!statusMessage.empty())
 					purple_savedstatus_set_message(status,statusMessage.c_str());
@@ -910,13 +912,13 @@ void User::receivedPresence(Stanza *stan
 		
 		// send presence about tranport status to user
 		if(m_connected || m_readyForConnect) {
-			Stanza *tag = Stanza::createPresenceStanza(m_jid, stanza->status(),stanza->presence());
-			tag->addAttribute( "from", p->jid() );
+			Presence tag(stanza.presence(), m_jid, stanza.status());
+			tag.setFrom(p->jid());
 			p->j->send( tag );
 		} else {
 			if (m_resource.empty()){
 				Tag *tag = new Tag("presence");
-				tag->addAttribute( "to", stanza->from().bare() );
+				tag->addAttribute( "to", stanza.from().bare() );
 				tag->addAttribute( "type", "unavailable" );
 				tag->addAttribute( "from", p->jid() );
 				p->j->send( tag );
============================================================
--- user.h	06709b8aea12ee3b8dbe6f6ed60a7f1b9eab8091
+++ user.h	901f83b26dfdfda1d36248f5d8dbf3db112c5112
@@ -81,8 +81,9 @@ class User {
 		void purpleReauthorizeBuddy(PurpleBuddy *buddy);
 
 		// Gloox callbacks
-		void receivedPresence(Stanza *stanza);
-		void receivedMessage( Stanza* stanza);
+		void receivedPresence(const Presence &presence);
+		void receivedSubscription(const Subscription &subscription);
+		void receivedMessage(const Message& msg);
 		void receivedChatState(const std::string &uin,const std::string &state);
 
 		// Libpurple callbacks
============================================================
--- vcardhandler.cpp	034dc1640f92c658ca044dbe5e9fbcce1f9f145a
+++ vcardhandler.cpp	3e17547df0383eb3c2190d6d6b97c6b314648705
@@ -89,25 +89,25 @@ GlooxVCardHandler::~GlooxVCardHandler(){
 GlooxVCardHandler::~GlooxVCardHandler(){
 }
 
-bool GlooxVCardHandler::handleIq (Stanza *stanza){
+bool GlooxVCardHandler::handleIq (const IQ &stanza){
 
-	if (stanza->from().username()=="")
+	if (stanza.from().username()=="")
 		return false;
 
-	User *user = p->userManager()->getUserByJID(stanza->from().bare());
+	User *user = p->userManager()->getUserByJID(stanza.from().bare());
 	if (user==NULL)
 		return false;
 	if (!user->isConnected()){
 		return false;
 	}
 
-	if(stanza->subtype() == StanzaIqGet) {
+	if(stanza.subtype() == IQ::Get) {
 		std::list<std::string> temp;
-		temp.push_back((std::string)stanza->id());
-		temp.push_back((std::string)stanza->from().full());
-		vcardRequests[(std::string)stanza->to().username()]=temp;
+		temp.push_back((std::string)stanza.id());
+		temp.push_back((std::string)stanza.from().full());
+		vcardRequests[(std::string)stanza.to().username()]=temp;
 		
-		serv_get_info(purple_account_get_connection(user->account()), stanza->to().username().c_str());
+		serv_get_info(purple_account_get_connection(user->account()), stanza.to().username().c_str());
 	}
 
 	return true;
@@ -254,6 +254,5 @@ void GlooxVCardHandler::userInfoArrived(
 	}
 }
 
-bool GlooxVCardHandler::handleIqID (Stanza *stanza, int context){
-	return false;
+void GlooxVCardHandler::handleIqID (const IQ &iq, int context){
 }
============================================================
--- vcardhandler.h	de2992a7ebc37962beb475b77a3fde7e07e87bd2
+++ vcardhandler.h	8ec7db51ec3fe4340fc1f01535d974c863e2b747
@@ -69,8 +69,8 @@ public:
 public:
 	GlooxVCardHandler(GlooxMessageHandler *parent);
 	~GlooxVCardHandler();
-	bool handleIq (Stanza *stanza);
-	bool handleIqID (Stanza *stanza, int context);
+	bool handleIq (const IQ &iq);
+	void handleIqID (const IQ &iq, int context);
 	bool hasVCardRequest (const std::string &name);
 	void userInfoArrived(PurpleConnection *gc,std::string who, PurpleNotifyUserInfo *user_info);
 	GlooxMessageHandler *p;
============================================================
--- xpinghandler.cpp	c959cde38dfa0b8d48786e546d4a9e5c799bf5f3
+++ xpinghandler.cpp	afc5dd22fa9ae92b06c49bfb32ddf72b427f7ba5
@@ -27,16 +27,16 @@ GlooxXPingHandler::~GlooxXPingHandler(){
 GlooxXPingHandler::~GlooxXPingHandler(){
 }
 
-bool GlooxXPingHandler::handleIq (Stanza *stanza){
-	Stanza *s = Stanza::createIqStanza(stanza->from(), stanza->id(), StanzaIqResult, "urn:xmpp:ping");
-
+bool GlooxXPingHandler::handleIq (const IQ &iq){
+	IQ s(IQ::Result, iq.from(), iq.id());
 	std::string from;
 	from.append(p->jid());
-	s->addAttribute("from",from);
-	p->j->send( s );
+	s.setFrom(from);
+	Tag *tag = s.tag();
+	tag->setXmlns("urn:xmpp:ping");
+	p->j->send(tag);
 	return true;
 }
 
-bool GlooxXPingHandler::handleIqID (Stanza *stanza, int context){
-	return false;
+void GlooxXPingHandler::handleIqID (const IQ &iq, int context){
 }
============================================================
--- xpinghandler.h	e2940ea610aebdbd406846d047157905aaf1c7c9
+++ xpinghandler.h	167bf18fcfe1ffd5a59c2cc5ce617be416b63ddb
@@ -40,8 +40,8 @@ public:
 public:
 	GlooxXPingHandler(GlooxMessageHandler *parent);
 	~GlooxXPingHandler();
-	bool handleIq (Stanza *stanza);
-	bool handleIqID (Stanza *stanza, int context);
+	bool handleIq (const IQ &iq);
+	void handleIqID (const IQ &iq, int context);
 	GlooxMessageHandler *p;
 };
 


More information about the Commits mailing list