Remove from memory also users which disconnected because of error
This commit is contained in:
parent
13d843e186
commit
0d320a2990
6 changed files with 25 additions and 46 deletions
|
@ -253,7 +253,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
|||
PurpleAccount *account = m_sessions[user];
|
||||
if (account) {
|
||||
// VALGRIND_DO_LEAK_CHECK;
|
||||
m_sessions[user] = NULL;
|
||||
m_sessions.erase(user);
|
||||
purple_account_set_enabled(account, "spectrum", FALSE);
|
||||
|
||||
// Remove conversations.
|
||||
|
@ -851,6 +851,7 @@ static PurpleConversationUiOps conversation_ui_ops =
|
|||
static void connection_report_disconnect(PurpleConnection *gc, PurpleConnectionError reason, const char *text){
|
||||
PurpleAccount *account = purple_connection_get_account(gc);
|
||||
np->handleDisconnected(np->m_accounts[account], purple_account_get_username(account), (int) reason, text ? text : "");
|
||||
np->handleLogoutRequest(np->m_accounts[account], purple_account_get_username(account));
|
||||
}
|
||||
|
||||
static PurpleConnectionUiOps conn_ui_ops =
|
||||
|
|
|
@ -32,7 +32,8 @@ class RosterManager;
|
|||
|
||||
typedef enum { BUDDY_NO_FLAG = 0,
|
||||
BUDDY_JID_ESCAPING = 2,
|
||||
BUDDY_IGNORE = 4
|
||||
BUDDY_IGNORE = 4,
|
||||
BUDDY_BLOCKED = 8,
|
||||
} BuddyFlag;
|
||||
|
||||
/// Represents one legacy network Buddy.
|
||||
|
@ -78,25 +79,17 @@ class Buddy {
|
|||
/// \return Presence stanza or NULL.
|
||||
Swift::Presence::ref generatePresenceStanza(int features, bool only_new = false);
|
||||
|
||||
/// Marks this buddy as available.
|
||||
void setOnline();
|
||||
|
||||
/// Marks this buddy as offline.
|
||||
void setOffline();
|
||||
|
||||
void setBlocked(bool block) {
|
||||
m_blocked = block;
|
||||
if (block)
|
||||
m_flags = (BuddyFlag) (m_flags | BUDDY_BLOCKED);
|
||||
else
|
||||
m_flags = (BuddyFlag) (m_flags & ~BUDDY_BLOCKED);
|
||||
}
|
||||
|
||||
bool isBlocked() {
|
||||
return m_blocked;
|
||||
return m_flags & BUDDY_BLOCKED;
|
||||
}
|
||||
|
||||
/// Returns true if this buddy is marked as available/online.
|
||||
|
||||
/// \return true if this buddy is marked as available/online.
|
||||
bool isOnline();
|
||||
|
||||
/// Sets current subscription.
|
||||
|
||||
/// \param subscription "to", "from", "both", "ask"
|
||||
|
@ -105,7 +98,7 @@ class Buddy {
|
|||
/// Returns current subscription
|
||||
|
||||
/// \return subscription "to", "from", "both", "ask"
|
||||
const std::string &getSubscription();
|
||||
const std::string getSubscription();
|
||||
|
||||
/// Sets this buddy's flags.
|
||||
|
||||
|
@ -137,9 +130,6 @@ class Buddy {
|
|||
/// \param vcard VCard which will be sent.
|
||||
void handleVCardReceived(const std::string &id, Swift::VCard::ref vcard);
|
||||
|
||||
/// This signal is emitted when buddyChanged method is called.
|
||||
boost::signal<void ()> onBuddyChanged;
|
||||
|
||||
/// Returns legacy network username of this buddy. (for example UIN for ICQ, JID for Jabber, ...).
|
||||
|
||||
/// \return legacy network username
|
||||
|
@ -177,9 +167,6 @@ class Buddy {
|
|||
void generateJID();
|
||||
|
||||
long m_id;
|
||||
bool m_online;
|
||||
bool m_blocked;
|
||||
std::string m_subscription;
|
||||
// Swift::Presence::ref m_lastPresence;
|
||||
Swift::JID m_jid;
|
||||
BuddyFlag m_flags;
|
||||
|
|
|
@ -80,6 +80,8 @@ class RosterManager {
|
|||
|
||||
boost::signal<void (Buddy *buddy)> onBuddyRemoved;
|
||||
|
||||
void handleBuddyChanged(Buddy *buddy);
|
||||
|
||||
void handleSubscription(Swift::Presence::ref presence);
|
||||
|
||||
void sendBuddyRosterPush(Buddy *buddy);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
namespace Transport {
|
||||
|
||||
Buddy::Buddy(RosterManager *rosterManager, long id) : m_id(id), m_online(false), m_blocked(false), m_subscription("ask"), m_flags(BUDDY_NO_FLAG), m_rosterManager(rosterManager){
|
||||
Buddy::Buddy(RosterManager *rosterManager, long id) : m_id(id), m_flags(BUDDY_NO_FLAG), m_rosterManager(rosterManager){
|
||||
// m_rosterManager->setBuddy(this);
|
||||
}
|
||||
|
||||
|
@ -64,25 +64,12 @@ const Swift::JID &Buddy::getJID() {
|
|||
return m_jid;
|
||||
}
|
||||
|
||||
void Buddy::setOnline() {
|
||||
m_online = true;
|
||||
}
|
||||
|
||||
void Buddy::setOffline() {
|
||||
m_online = false;
|
||||
// m_lastPresence = Swift::Presence::ref();
|
||||
}
|
||||
|
||||
bool Buddy::isOnline() {
|
||||
return m_online;
|
||||
}
|
||||
|
||||
void Buddy::setSubscription(const std::string &subscription) {
|
||||
m_subscription = subscription;
|
||||
// m_subscription = subscription;
|
||||
}
|
||||
|
||||
const std::string &Buddy::getSubscription() {
|
||||
return m_subscription;
|
||||
const std::string Buddy::getSubscription() {
|
||||
return "ask";
|
||||
}
|
||||
|
||||
Swift::Presence::ref Buddy::generatePresenceStanza(int features, bool only_new) {
|
||||
|
@ -113,7 +100,7 @@ Swift::Presence::ref Buddy::generatePresenceStanza(int features, bool only_new)
|
|||
// if (features & 0/*TRANSPORT_FEATURE_AVATARS*/) {
|
||||
presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::VCardUpdate (getIconHash())));
|
||||
// }
|
||||
if (m_blocked) {
|
||||
if (isBlocked()) {
|
||||
presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::BlockPayload ()));
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +142,7 @@ void Buddy::handleBuddyChanged() {
|
|||
if (presence) {
|
||||
m_rosterManager->getUser()->getComponent()->getStanzaChannel()->sendPresence(presence);
|
||||
}
|
||||
onBuddyChanged();
|
||||
m_rosterManager->handleBuddyChanged(this);
|
||||
}
|
||||
|
||||
void Buddy::handleVCardReceived(const std::string &id, Swift::VCard::ref vcard) {
|
||||
|
|
|
@ -170,6 +170,7 @@ static void handleBuddyPayload(LocalBuddy *buddy, const pbnetwork::Buddy &payloa
|
|||
}
|
||||
|
||||
NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, UserManager *userManager) {
|
||||
std::cout << "BUDDY " << sizeof(Buddy) << "\n";
|
||||
m_userManager = userManager;
|
||||
m_config = config;
|
||||
m_component = component;
|
||||
|
|
|
@ -100,13 +100,15 @@ void RosterManager::sendBuddySubscribePresence(Buddy *buddy) {
|
|||
m_component->getStanzaChannel()->sendPresence(response);
|
||||
}
|
||||
|
||||
void RosterManager::handleBuddyChanged(Buddy *buddy) {
|
||||
if (m_rosterStorage) {
|
||||
m_rosterStorage->storeBuddy(buddy);
|
||||
}
|
||||
}
|
||||
|
||||
void RosterManager::setBuddyCallback(Buddy *buddy) {
|
||||
m_setBuddyTimer->onTick.disconnect(boost::bind(&RosterManager::setBuddyCallback, this, buddy));
|
||||
|
||||
if (m_rosterStorage) {
|
||||
buddy->onBuddyChanged.connect(boost::bind(&RosterStorage::storeBuddy, m_rosterStorage, buddy));
|
||||
}
|
||||
|
||||
LOG4CXX_INFO(logger, "Associating buddy " << buddy->getName() << " with " << m_user->getJID().toString());
|
||||
m_buddies[buddy->getName()] = buddy;
|
||||
onBuddySet(buddy);
|
||||
|
@ -350,7 +352,6 @@ void RosterManager::setStorageBackend(StorageBackend *storageBackend) {
|
|||
Buddy *buddy = m_component->getFactory()->createBuddy(this, *it);
|
||||
LOG4CXX_INFO(logger, m_user->getJID().toString() << ": Adding cached buddy " << buddy->getName() << " fom database");
|
||||
m_buddies[buddy->getName()] = buddy;
|
||||
buddy->onBuddyChanged.connect(boost::bind(&RosterStorage::storeBuddy, m_rosterStorage, buddy));
|
||||
onBuddySet(buddy);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue