Files
@ e31c07794705
Branch filter:
Location: libtransport.git/include/transport/usermanager.h - annotation
e31c07794705
3.3 KiB
text/plain
Call finishSession in User destructor in server mode
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 | c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 1e8eb7076f17 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 2ae880ff94b5 c0a01941fc10 525a07a4d19a c5edfd19b1aa 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 c5edfd19b1aa 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 1e8eb7076f17 2ae880ff94b5 2ae880ff94b5 c5edfd19b1aa c5edfd19b1aa 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 34207065ceb5 34207065ceb5 34207065ceb5 34207065ceb5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 c5edfd19b1aa 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 c5edfd19b1aa 2ae880ff94b5 2ae880ff94b5 2ae880ff94b5 c5edfd19b1aa 1e8eb7076f17 1e8eb7076f17 1e8eb7076f17 1e8eb7076f17 25f5516757ed 25f5516757ed 25f5516757ed 25f5516757ed 9477e3f83882 1e8eb7076f17 c5edfd19b1aa c5edfd19b1aa c8006a0ebab6 5797b554ea69 5797b554ea69 5797b554ea69 5f017bd15dc7 2ae880ff94b5 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 2ae880ff94b5 2ae880ff94b5 c0a01941fc10 1e8eb7076f17 8ab47cce7012 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa | /**
* 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
*/
#pragma once
#include <string>
#include <map>
#include "Swiften/Swiften.h"
#include "transport/userregistry.h"
namespace Transport {
class User;
class Component;
class StorageBackend;
class StorageResponder;
class RosterResponder;
/// Manages online XMPP Users.
/// This class handles presences and creates User classes when new user connects.
/// It also removes the User class once the last user's resource disconnected.
class UserManager {
public:
/// Creates new UserManager.
/// \param component Component which's presence will be handled
/// \param storageBackend Storage backend used to fetch UserInfos
UserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend = NULL);
/// Destroys UserManager.
~UserManager();
/// Returns user according to his bare JID.
/// \param barejid bare JID of user
/// \return User class associated with this user
User *getUser(const std::string &barejid);
const std::map<std::string, User *> &getUsers() {
return m_users;
}
/// Returns number of online users.
/// \return number of online users
int getUserCount();
/// Removes user. This function disconnects user and safely removes
/// User class. This does *not* remove user from database.
/// \param user User class to remove
void removeUser(User *user);
/// Called when new User class is created.
/// \param user newly created User class
boost::signal<void (User *user)> onUserCreated;
/// Called when User class is going to be removed
/// \param user removed User class
boost::signal<void (User *user)> onUserDestroyed;
bool isUserConnected(const std::string &barejid) const {
return m_users.find(barejid) != m_users.end();
}
UserRegistry *getUserRegistry() {
return m_userRegistry;
}
void connectUser(const Swift::JID &user);
private:
void handlePresence(Swift::Presence::ref presence);
void handleMessageReceived(Swift::Message::ref message);
void handleGeneralPresenceReceived(Swift::Presence::ref presence);
void handleProbePresence(Swift::Presence::ref presence);
void handleSubscription(Swift::Presence::ref presence);
// void handleDiscoInfoResponse(boost::shared_ptr<Swift::DiscoInfo> info, Swift::ErrorPayload::ref error, const Swift::JID& jid);
void addUser(User *user);
long m_onlineBuddies;
User *m_cachedUser;
std::map<std::string, User *> m_users;
Component *m_component;
StorageBackend *m_storageBackend;
StorageResponder *m_storageResponder;
UserRegistry *m_userRegistry;
friend class RosterResponder;
};
}
|