Files
        @ 096324974ae8
    
        
              Branch filter: 
        
    Location: libtransport.git/spectrum/src/frontends/xmpp/XMPPUserManager.cpp
        
            
            096324974ae8
            3.8 KiB
            text/x-c++hdr
        
        
    
    Update Travis CI badge url
    | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /**
 * libtransport -- C++ library for easy XMPP Transports development
 *
 * Copyright (C) 2011, Jan Kaluza <hanzz.k@gmail.com>
 *
 * 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 "XMPPUserManager.h"
#include "XMPPUserRegistration.h"
#include "transport/User.h"
#include "transport/Transport.h"
#include "transport/StorageBackend.h"
#include "transport/Logging.h"
#include "transport/Frontend.h"
#include "storageresponder.h"
#include "vcardresponder.h"
#include "XMPPFrontend.h"
#include "gatewayresponder.h"
#include "adhocmanager.h"
#include "settingsadhoccommand.h"
#include "Swiften/Server/ServerStanzaChannel.h"
#include "Swiften/Elements/StreamError.h"
#include "Swiften/Elements/MUCPayload.h"
#include "Swiften/Elements/ChatState.h"
#ifndef __FreeBSD__ 
#ifndef __MACH__
#include "malloc.h"
#endif
#endif
// #include "valgrind/memcheck.h"
namespace Transport {
DEFINE_LOGGER(logger, "XMPPUserManager");
XMPPUserManager::XMPPUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend) : UserManager(component, userRegistry, storageBackend) {
	m_component = component;
	XMPPFrontend *frontend = static_cast<XMPPFrontend *>(component->getFrontend());
	if (storageBackend) {
		m_storageResponder = new StorageResponder(frontend->getIQRouter(), storageBackend, this);
		m_storageResponder->start();
	}
	m_vcardResponder = new VCardResponder(frontend->getIQRouter(), component->getNetworkFactories(), this);
	m_vcardResponder->onVCardRequired.connect(boost::bind(&XMPPUserManager::handleVCardRequired, this, _1, _2, _3));
	m_vcardResponder->onVCardUpdated.connect(boost::bind(&XMPPUserManager::handleVCardUpdated, this, _1, _2));
	m_vcardResponder->start();
	if (storageBackend) {
		m_userRegistration = new XMPPUserRegistration(component, this, storageBackend);
		m_userRegistration->start();
	}
	else {
		m_userRegistration = NULL;
	}
// 	StatsResponder statsResponder(component, this, &plugin, storageBackend);
// 	statsResponder.start();
	m_gatewayResponder = new GatewayResponder(frontend->getIQRouter(), this);
	m_gatewayResponder->start();
	m_adHocManager = new AdHocManager(component, frontend->getDiscoItemsResponder(), this, storageBackend);
	m_adHocManager->start();
	SettingsAdHocCommandFactory *m_settings = new SettingsAdHocCommandFactory();
	m_adHocManager->addAdHocCommand(m_settings);
}
XMPPUserManager::~XMPPUserManager() {
	if (m_storageResponder) {
		m_storageResponder->stop();
		delete m_storageResponder;
	}
	if (m_userRegistration) {
		m_userRegistration->stop();
		delete m_userRegistration;
	}
	delete m_gatewayResponder;
	delete m_adHocManager;
	delete m_settings;
	delete m_vcardResponder;
}
void XMPPUserManager::sendVCard(unsigned int id, Swift::VCard::ref vcard) {
	m_vcardResponder->sendVCard(id, vcard);
}
void XMPPUserManager::handleVCardRequired(User *user, const std::string &name, unsigned int id) {
	m_component->getFrontend()->onVCardRequired(user, name, id);
}
void XMPPUserManager::handleVCardUpdated(User *user, boost::shared_ptr<Swift::VCard> vcard) {
	m_component->getFrontend()->onVCardUpdated(user, vcard);
}
UserRegistration *XMPPUserManager::getUserRegistration() {
	return m_userRegistration;
}
}
 |