Changeset - 76c678dd6f1d
[Not reviewed]
0 5 6
HanzZ - 14 years ago 2011-04-01 23:54:29
hanzz.k@gmail.com
Working conversation from legacy -> XMPP
11 files changed with 377 insertions and 6 deletions:
0 comments (0 inline, 0 general)
include/transport/abstractconversation.h
Show inline comments
 
new file 100644
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@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
 
 */
 

	
 
#pragma once
 

	
 
#include <string>
 
#include <algorithm>
 
#include "transport/transport.h"
 

	
 
#include "Swiften/Swiften.h"
 
#include "Swiften/Elements/Message.h"
 

	
 
namespace Transport {
 

	
 
class ConversationManager;
 

	
 
class AbstractConversation {
 
	public:
 
		/// Constructor.
 
		AbstractConversation(ConversationManager *conversationManager, const std::string &legacyName);
 

	
 
		/// Destructor
 
		virtual ~AbstractConversation();
 

	
 
		const std::string &getLegacyName() { return m_legacyName; }
 

	
 
		void handleMessage(boost::shared_ptr<Swift::Message> &message);
 

	
 
		virtual void sendMessage(boost::shared_ptr<Swift::Message> &message) = 0;
 

	
 
	private:
 
		ConversationManager *m_conversationManager;
 
		std::string m_legacyName;
 
};
 

	
 
}
include/transport/conversationmanager.h
Show inline comments
 
new file 100644
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@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
 
 */
 

	
 
#pragma once
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 
#include "Swiften/Swiften.h"
 

	
 
namespace Transport {
 

	
 
class AbstractConversation;
 
class User;
 
class Component;
 

	
 
class ConversationManager {
 
	public:
 
		/// Creates new ConversationManager.
 
		/// \param user User associated with this ConversationManager.
 
		/// \param component Transport instance associated with this roster.
 
		ConversationManager(User *user, Component *component);
 

	
 
		/// Destructor.
 
		virtual ~ConversationManager();
 

	
 
		/// Returns user associated with this manager.
 
		/// \return User
 
		User *getUser() { return m_user; }
 

	
 
		Component *getComponent() { return m_component; }
 

	
 
		void setConversation(AbstractConversation *conv);
 

	
 
		void unsetConversation(AbstractConversation *conv);
 

	
 
	private:
 
		Component *m_component;
 
		User *m_user;
 

	
 
		std::map<std::string, AbstractConversation *> m_convs;
 
};
 

	
 
}
include/transport/rostermanager.h
Show inline comments
 
@@ -45,24 +45,26 @@ class RosterManager {
 

	
 
		/// Associates the buddy with this roster,
 
		/// and if the buddy is not already in XMPP user's server-side roster, the proper requests
 
		/// are sent to XMPP user (subscribe presences, Roster Item Exchange stanza or
 
		/// the buddy is added to server-side roster using remote-roster protoXEP).
 
		/// \param buddy AbstractBuddy
 
		void setBuddy(AbstractBuddy *buddy);
 

	
 
		/// Deassociates the buddy with this roster.
 
		/// \param buddy AbstractBuddy.
 
		void unsetBuddy(AbstractBuddy *buddy);
 

	
 
		AbstractBuddy *getBuddy(const std::string &name);
 

	
 
		/// Returns user associated with this roster.
 
		/// \return User
 
		User *getUser() { return m_user; }
 

	
 
		/// Called when new AbstractBuddy is added to this roster.
 
		/// \param buddy newly added AbstractBuddy
 
		boost::signal<void (AbstractBuddy *buddy)> onBuddySet;
 

	
 
		/// Called when AbstractBuddy has been removed from this roster.
 
		/// \param buddy removed AbstractBuddy
 
		boost::signal<void (AbstractBuddy *buddy)> onBuddyUnset;
 

	
include/transport/user.h
Show inline comments
 
@@ -21,24 +21,25 @@
 
#pragma once
 

	
 
#include <time.h>
 
#include "Swiften/Swiften.h"
 
#include "Swiften/Presence/PresenceOracle.h"
 
#include "Swiften/Disco/EntityCapsManager.h"
 
#include "storagebackend.h"
 

	
 
namespace Transport {
 

	
 
class Component;
 
class RosterManager;
 
class ConversationManager;
 
struct UserInfo;
 

	
 
/// Represents online XMPP user.
 
class User {
 
	public:
 
		/// Creates new User class.
 
		/// \param jid XMPP JID associated with this user
 
		/// \param userInfo UserInfo struct with informations needed to connect
 
		/// this user to legacy network
 
		/// \param component Component associated with this user
 
		User(const Swift::JID &jid, UserInfo &userInfo, Component * component);
 

	
 
@@ -46,44 +47,47 @@ class User {
 
		virtual ~User();
 

	
 
		/// Returns JID of XMPP user who is currently connected using this User class.
 
		/// \return full JID
 
		const Swift::JID &getJID();
 

	
 
		/// Returns UserInfo struct with informations needed to connect the legacy network.
 
		/// \return UserInfo struct
 
		UserInfo &getUserInfo() { return m_userInfo; }
 

	
 
		RosterManager *getRosterManager() { return m_rosterManager; }
 

	
 
		ConversationManager *getConversationManager() { return m_conversationManager; }
 

	
 

	
 
		Component *getComponent() { return m_component; }
 

	
 
		void setData(void *data) { m_data = data; }
 
		void *getData() { return m_data; }
 

	
 
		/// Handles presence from XMPP JID associated with this user.
 
		/// \param presence Swift::Presence.
 
		void handlePresence(Swift::Presence::ref presence);
 

	
 
		/// Returns language.
 
		/// \return language
 
		const char *getLang() { return "en"; }
 

	
 
		boost::signal<void ()> onReadyToConnect;
 

	
 
	private:
 
		void onConnectingTimeout();
 

	
 
		Swift::JID m_jid;
 
		Component *m_component;
 
		RosterManager *m_rosterManager;
 
		ConversationManager *m_conversationManager;
 
		Swift::EntityCapsManager *m_entityCapsManager;
 
		Swift::PresenceOracle *m_presenceOracle;
 
		UserInfo m_userInfo;
 
		void *m_data;
 
		bool m_connected;
 
		bool m_readyForConnect;
 
		Swift::Timer::ref m_reconnectTimer;
 
};
 

	
 
}
spectrum/src/main.cpp
Show inline comments
 
@@ -4,24 +4,25 @@
 

	
 
#include "transport/config.h"
 
#include "transport/transport.h"
 
#include "transport/usermanager.h"
 
#include "transport/logger.h"
 
#include "transport/sqlite3backend.h"
 
#include "transport/userregistration.h"
 
#include "transport/user.h"
 
#include "transport/storagebackend.h"
 
#include "transport/rostermanager.h"
 
#include "spectrumeventloop.h"
 
#include "spectrumbuddy.h"
 
#include "spectrumconversation.h"
 
#include "geventloop.h"
 

	
 
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
 

	
 

	
 
using namespace Transport;
 

	
 
Logger *_logger;
 

	
 
static gboolean nodaemon = FALSE;
 
static gchar *logfile = NULL;
 
static gchar *lock_file = NULL;
 
@@ -100,26 +101,26 @@ static void buddySignedOff(PurpleBuddy *buddy) {
 

	
 
	if (!user || !s_buddy)
 
		return;
 

	
 
	s_buddy->buddyChanged();
 
}
 

	
 
static void NodeRemoved(PurpleBlistNode *node, void *data) {
 
	if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
 
		return;
 
	PurpleBuddy *buddy = (PurpleBuddy *) node;
 
	
 
	PurpleAccount *account = purple_buddy_get_account(buddy);
 
	User *user = (User *) account->ui_data;
 
// 	PurpleAccount *account = purple_buddy_get_account(buddy);
 
// 	User *user = (User *) account->ui_data;
 
	if (buddy->node.ui_data) {
 
		SpectrumBuddy *s_buddy = (SpectrumBuddy *) buddy->node.ui_data;
 
		s_buddy->removeBuddy(buddy);
 
		buddy->node.ui_data = NULL;
 
		if (s_buddy->getBuddiesCount() == 0) {
 
			delete s_buddy;
 
		}
 
	}
 
}
 

	
 
static PurpleBlistUiOps blistUiOps =
 
{
 
@@ -130,33 +131,90 @@ static PurpleBlistUiOps blistUiOps =
 
	NULL, //NodeRemoved,
 
	NULL,
 
	NULL,
 
	NULL, // buddyListAddBuddy,
 
	NULL,
 
	NULL,
 
	NULL, //buddyListSaveNode,
 
	NULL, //buddyListRemoveNode,
 
	NULL, //buddyListSaveAccount,
 
	NULL
 
};
 

	
 
static void conv_new(PurpleConversation *conv) {
 
	PurpleAccount *account = purple_conversation_get_account(conv);
 
	User *user = (User *) account->ui_data;
 

	
 
	if (!user)
 
		return;
 

	
 
	std::string name = purple_conversation_get_name(conv);
 
	size_t pos = name.find("/");
 
	if (pos != std::string::npos)
 
		name.erase((int) pos, name.length() - (int) pos);
 

	
 
	SpectrumConversation *s_conv = new SpectrumConversation(user->getConversationManager(), name, conv);
 
	conv->ui_data = s_conv;
 
}
 

	
 
static void conv_destroy(PurpleConversation *conv) {
 
	SpectrumConversation *s_conv = (SpectrumConversation *) conv->ui_data;
 
	if (s_conv) {
 
		delete s_conv;
 
	}
 
}
 

	
 
static void conv_write_im(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime) {
 
	SpectrumConversation *s_conv = (SpectrumConversation *) conv->ui_data;
 
	if (!s_conv)
 
		return;
 

	
 
	boost::shared_ptr<Swift::Message> msg(new Swift::Message());
 
	msg->setBody(message);
 

	
 
	s_conv->handleMessage(msg);
 
}
 

	
 
static PurpleConversationUiOps conversation_ui_ops =
 
{
 
	conv_new,
 
	conv_destroy,
 
	NULL,//conv_write_chat,                              /* write_chat           */
 
	conv_write_im,             /* write_im             */
 
	NULL,//conv_write_conv,           /* write_conv           */
 
	NULL,//conv_chat_add_users,       /* chat_add_users       */
 
	NULL,//conv_chat_rename_user,     /* chat_rename_user     */
 
	NULL,//conv_chat_remove_users,    /* chat_remove_users    */
 
	NULL,//pidgin_conv_chat_update_user,     /* chat_update_user     */
 
	NULL,//pidgin_conv_present_conversation, /* present              */
 
	NULL,//pidgin_conv_has_focus,            /* has_focus            */
 
	NULL,//pidgin_conv_custom_smiley_add,    /* custom_smiley_add    */
 
	NULL,//pidgin_conv_custom_smiley_write,  /* custom_smiley_write  */
 
	NULL,//pidgin_conv_custom_smiley_close,  /* custom_smiley_close  */
 
	NULL,//pidgin_conv_send_confirm,         /* send_confirm         */
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL
 
};
 

	
 
static void transport_core_ui_init(void)
 
{
 
	purple_blist_set_ui_ops(&blistUiOps);
 
// 	purple_accounts_set_ui_ops(&accountUiOps);
 
// 	purple_notify_set_ui_ops(&notifyUiOps);
 
// 	purple_request_set_ui_ops(&requestUiOps);
 
// 	purple_xfers_set_ui_ops(getXferUiOps());
 
// 	purple_connections_set_ui_ops(&conn_ui_ops);
 
// 	purple_conversations_set_ui_ops(&conversation_ui_ops);
 
	purple_conversations_set_ui_ops(&conversation_ui_ops);
 
// #ifndef WIN32
 
// 	purple_dnsquery_set_ui_ops(getDNSUiOps());
 
// #endif
 
}
 

	
 
static PurpleCoreUiOps coreUiOps =
 
{
 
	NULL,
 
// 	debug_init,
 
	NULL,
 
	transport_core_ui_init,
 
	NULL,
 
@@ -187,24 +245,26 @@ static PurpleDebugUiOps debugUiOps =
 
	printDebug,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL,
 
	NULL
 
};
 

	
 
static bool initPurple(Config &cfg) {
 
	bool ret;
 

	
 
	purple_util_set_user_dir("./");
 
	remove("./accounts.xml");
 
	remove("./blist.xml");
 

	
 
// 	if (m_configuration.logAreas & LOG_AREA_PURPLE)
 
		purple_debug_set_ui_ops(&debugUiOps);
 

	
 
	purple_core_set_ui_ops(&coreUiOps);
 
	purple_eventloop_set_ui_ops(getEventLoopUiOps());
 

	
 
	ret = purple_core_init("spectrum");
 
	if (ret) {
 
		static int conversation_handle;
 
		static int conn_handle;
 
		static int blist_handle;
spectrum/src/spectrumconversation.cpp
Show inline comments
 
new file 100644
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@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 "spectrumconversation.h"
 
#include "transport/user.h"
 

	
 
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
 

	
 
SpectrumConversation::SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv) : AbstractConversation(conversationManager, legacyName), m_conv(conv) {
 
}
 

	
 
SpectrumConversation::~SpectrumConversation() {
 
}
 

	
 
void SpectrumConversation::sendMessage(boost::shared_ptr<Swift::Message> &message) {
 
	
 
}
 

	
 

	
spectrum/src/spectrumconversation.h
Show inline comments
 
new file 100644
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@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
 
 */
 

	
 
#pragma once
 

	
 
#include <string>
 
#include "purple.h"
 
#include "account.h"
 
#include "glib.h"
 
#include <algorithm>
 
#include "transport/abstractconversation.h"
 
#include "transport/conversationmanager.h"
 

	
 
using namespace Transport;
 

	
 
// Wrapper for PurpleBuddy
 
class SpectrumConversation : public AbstractConversation {
 
	public:
 
		SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv);
 
		virtual ~SpectrumConversation();
 
		
 
		PurpleConversation *getConversation() { return m_conv; }
 

	
 
		void sendMessage(boost::shared_ptr<Swift::Message> &message);
 

	
 
	private:
 
		PurpleConversation *m_conv;
 
};
 

	
src/abstractconversation.cpp
Show inline comments
 
new file 100644
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@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 <iostream>
 
#include "transport/abstractconversation.h"
 
#include "transport/conversationmanager.h"
 
#include "transport/user.h"
 
#include "transport/transport.h"
 
#include "transport/abstractbuddy.h"
 
#include "transport/rostermanager.h"
 

	
 
namespace Transport {
 

	
 
AbstractConversation::AbstractConversation(ConversationManager *conversationManager, const std::string &legacyName) : m_conversationManager(conversationManager) {
 
	m_conversationManager->setConversation(this);
 
	m_legacyName = legacyName;
 
}
 

	
 
AbstractConversation::~AbstractConversation() {
 
	m_conversationManager->unsetConversation(this);
 
}
 

	
 
void AbstractConversation::handleMessage(boost::shared_ptr<Swift::Message> &message) {
 
	message->setTo(m_conversationManager->getUser()->getJID().toBare());
 
	AbstractBuddy *buddy = m_conversationManager->getUser()->getRosterManager()->getBuddy(m_legacyName);
 
	if (buddy) {
 
		std::cout << m_legacyName << " 222222\n";
 
		message->setFrom(buddy->getJID());
 
	}
 
	else {
 
		std::cout << m_legacyName << " 1111111\n";
 
		// TODO: escape from and setFrom
 
	}
 
	m_conversationManager->getComponent()->getStanzaChannel()->sendMessage(message);
 
}
 

	
 
}
src/conversationmanager.cpp
Show inline comments
 
new file 100644
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@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 "transport/conversationmanager.h"
 
#include "transport/abstractconversation.h"
 
#include "transport/usermanager.h"
 
#include "transport/abstractbuddy.h"
 
#include "transport/user.h"
 
#include "Swiften/Roster/SetRosterRequest.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/Elements/RosterItemPayload.h"
 

	
 
namespace Transport {
 

	
 
ConversationManager::ConversationManager(User *user, Component *component){
 
	m_user = user;
 
	m_component = component;
 
}
 

	
 
ConversationManager::~ConversationManager() {
 
}
 

	
 
void ConversationManager::setConversation(AbstractConversation *conv) {
 
	m_convs[conv->getLegacyName()] = conv;
 
}
 

	
 
void ConversationManager::unsetConversation(AbstractConversation *conv) {
 
	m_convs.erase(conv->getLegacyName());
 
}
 

	
 
}
 
\ No newline at end of file
src/rostermanager.cpp
Show inline comments
 
@@ -44,43 +44,47 @@ void RosterManager::setBuddy(AbstractBuddy *buddy) {
 
}
 

	
 
void RosterManager::sendBuddyRosterPush(AbstractBuddy *buddy) {
 
	Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload());
 
	Swift::RosterItemPayload item;
 
	item.setJID(buddy->getJID().toBare());
 
	item.setName(buddy->getAlias());
 
	item.setGroups(buddy->getGroups());
 

	
 
	payload->addItem(item);
 

	
 
	Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(payload, m_component->getIQRouter(), m_user->getJID().toBare());
 
	request->onResponse.connect(boost::bind(&RosterManager::handleBuddyRosterPushResponse, this, _1, buddy->getSafeName()));
 
	request->onResponse.connect(boost::bind(&RosterManager::handleBuddyRosterPushResponse, this, _1, buddy->getName()));
 
	request->send();
 
}
 

	
 
void RosterManager::setBuddyCallback(AbstractBuddy *buddy) {
 
	m_setBuddyTimer->onTick.disconnect(boost::bind(&RosterManager::setBuddyCallback, this, buddy));
 

	
 
	m_buddies[buddy->getSafeName()] = buddy;
 
	m_buddies[buddy->getName()] = buddy;
 
	onBuddySet(buddy);
 

	
 
	if (m_component->inServerMode()) {
 
		sendBuddyRosterPush(buddy);
 
	}
 

	
 
	if (m_setBuddyTimer->onTick.empty()) {
 
		m_setBuddyTimer->stop();
 
	}
 
}
 

	
 
void RosterManager::unsetBuddy(AbstractBuddy *buddy) {
 
	m_buddies.erase(buddy->getSafeName());
 
	m_buddies.erase(buddy->getName());
 
	onBuddyUnset(buddy);
 
}
 

	
 
void RosterManager::handleBuddyRosterPushResponse(Swift::ErrorPayload::ref error, const std::string &key) {
 
	if (m_buddies[key] != NULL) {
 
		m_buddies[key]->buddyChanged();
 
	}
 
}
 

	
 
AbstractBuddy *RosterManager::getBuddy(const std::string &name) {
 
	return m_buddies[name];
 
}
 

	
 
}
 
\ No newline at end of file
src/user.cpp
Show inline comments
 
@@ -13,46 +13,49 @@
 
 * 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 "transport/user.h"
 
#include "transport/transport.h"
 
#include "transport/storagebackend.h"
 
#include "transport/rostermanager.h"
 
#include "transport/conversationmanager.h"
 
#include "Swiften/Swiften.h"
 

	
 
namespace Transport {
 

	
 
User::User(const Swift::JID &jid, UserInfo &userInfo, Component *component) {
 
	m_jid = jid;
 

	
 
	m_component = component;
 
	m_presenceOracle = component->m_presenceOracle;
 
	m_entityCapsManager = component->m_entityCapsManager;
 
	m_userInfo = userInfo;
 
	m_connected = false;
 
	m_readyForConnect = false;
 

	
 
	m_reconnectTimer = m_component->getFactories()->getTimerFactory()->createTimer(10000);
 
	m_reconnectTimer->onTick.connect(boost::bind(&User::onConnectingTimeout, this)); 
 

	
 
	m_rosterManager = new RosterManager(this, m_component);
 
	m_conversationManager = new ConversationManager(this, m_component);
 
}
 

	
 
User::~User(){
 
	delete m_rosterManager;
 
	delete m_conversationManager;
 
}
 

	
 
const Swift::JID &User::getJID() {
 
	return m_jid;
 
}
 

	
 
void User::handlePresence(Swift::Presence::ref presence) {
 
	Swift::Presence::ref highest = m_presenceOracle->getHighestPriorityPresence(m_jid.toBare());
 

	
 
	if (!m_connected) {
 
		// we are not connected to legacy network, so we should do it when disco#info arrive :)
 
		if (m_readyForConnect == false) {
0 comments (0 inline, 0 general)