From 0ae646141ad258e72d69c3955d77c6a850b20aef Mon Sep 17 00:00:00 2001 From: maksis Date: Wed, 20 Jan 2016 15:32:16 +0200 Subject: [PATCH] Squashed 'airdcpp-core/' changes from 4fddc37..c00ee91 c00ee91 Fix issues with putting filelist/private chat sessions back online, fixes https://bugs.launchpad.net/airdcpp/+bug/1535696 git-subtree-dir: airdcpp-core git-subtree-split: c00ee91098d300ec233ce3e2f46b48aa74256488 --- airdcpp/DirectoryListing.cpp | 16 +++++---- airdcpp/DirectoryListing.h | 6 +++- airdcpp/PrivateChat.cpp | 66 +++++++++++++++++------------------- airdcpp/PrivateChat.h | 5 +-- airdcpp/StringDefs.h | 2 +- 5 files changed, 50 insertions(+), 45 deletions(-) diff --git a/airdcpp/DirectoryListing.cpp b/airdcpp/DirectoryListing.cpp index 5cf308a2..b28fc2f9 100644 --- a/airdcpp/DirectoryListing.cpp +++ b/airdcpp/DirectoryListing.cpp @@ -1063,14 +1063,18 @@ void DirectoryListing::matchQueueImpl() noexcept { } void DirectoryListing::on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool /*wentOffline*/) noexcept { - if (aUser != hintedUser.user) { - return; - } - - fire(DirectoryListingListener::UserUpdated()); + onUserUpdated(aUser); } void DirectoryListing::on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept { - if (aUser.getUser() != hintedUser.user) { + onUserUpdated(aUser); +} + +void DirectoryListing::on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool /*wasOffline*/) noexcept { + onUserUpdated(aUser); +} + +void DirectoryListing::onUserUpdated(const UserPtr& aUser) noexcept { + if (aUser != hintedUser.user) { return; } diff --git a/airdcpp/DirectoryListing.h b/airdcpp/DirectoryListing.h index becd3303..bbecdc68 100644 --- a/airdcpp/DirectoryListing.h +++ b/airdcpp/DirectoryListing.h @@ -274,8 +274,12 @@ class DirectoryListing : public intrusive_ptr_base, public Use // ClientManagerListener void on(ClientManagerListener::DirectSearchEnd, const string& aToken, int resultCount) noexcept; - void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept; + + void on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool wasOffline) noexcept; void on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept; + void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept; + + void onUserUpdated(const UserPtr& aUser) noexcept; void on(TimerManagerListener::Second, uint64_t aTick) noexcept; diff --git a/airdcpp/PrivateChat.cpp b/airdcpp/PrivateChat.cpp index 62ccc337..98f1256b 100644 --- a/airdcpp/PrivateChat.cpp +++ b/airdcpp/PrivateChat.cpp @@ -207,6 +207,37 @@ void PrivateChat::checkCCPMTimeout() { } } +void PrivateChat::onUserUpdated(const OnlineUser& aUser) noexcept { + if (aUser.getUser() != replyTo.user) + return; + + setSupportsCCPM(ClientManager::getInstance()->getSupportsCCPM(replyTo, lastCCPMError)); + delayEvents.addEvent(USER_UPDATE, [this] { + if (!online) { + auto hubNames = ClientManager::getInstance()->getFormatedHubNames(replyTo); + auto nicks = ClientManager::getInstance()->getFormatedNicks(replyTo); + statusMessage(STRING(USER_WENT_ONLINE) + " [" + nicks + " - " + hubNames + "]", + LogMessage::SEV_INFO); + + // online from a different hub? + checkUserHub(false); + online = true; + } + + fire(PrivateChatListener::UserUpdated(), this); + }, 1000); + + delayEvents.addEvent(CCPM_AUTO, [this] { checkAlwaysCCPM(); }, 3000); +} + +void PrivateChat::on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool /*wasOffline*/) noexcept { + onUserUpdated(aUser); +} + +void PrivateChat::on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept { + onUserUpdated(aUser); +} + void PrivateChat::on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept{ if (aUser != replyTo.user) return; @@ -232,18 +263,6 @@ void PrivateChat::on(ClientManagerListener::UserDisconnected, const UserPtr& aUs } } -/* -The hub window was closed, we might be using the client of it for messages(CCPM and status messages) and its soon to be deleted.. -This listener comes from the main thread so we should be able to pass the next speaker message before any other messages. -*/ -void PrivateChat::on(ClientManagerListener::ClientDisconnected, const string& aHubUrl) noexcept { - if (aHubUrl == getHubUrl()) { - checkUserHub(true); - fire(PrivateChatListener::UserUpdated(), this); - } -} - - void PrivateChat::checkUserHub(bool wentOffline) { auto hubs = ClientManager::getInstance()->getHubs(replyTo.user->getCID()); if (hubs.empty()) @@ -318,29 +337,6 @@ void PrivateChat::on(AdcCommand::PMI, UserConnection*, const AdcCommand& cmd) no fire(PrivateChatListener::PMStatus(), this, type); } -void PrivateChat::on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept{ - if (aUser.getUser() != replyTo.user) - return; - - setSupportsCCPM(ClientManager::getInstance()->getSupportsCCPM(replyTo, lastCCPMError)); - delayEvents.addEvent(USER_UPDATE, [this] { - if (!online) { - auto hubNames = ClientManager::getInstance()->getFormatedHubNames(replyTo); - auto nicks = ClientManager::getInstance()->getFormatedNicks(replyTo); - statusMessage(STRING(USER_WENT_ONLINE) + " [" + nicks + " - " + hubNames + "]", - LogMessage::SEV_INFO); - - // online from a different hub? - checkUserHub(false); - online = true; - } - - fire(PrivateChatListener::UserUpdated(), this); - }, 1000); - - delayEvents.addEvent(CCPM_AUTO, [this] { checkAlwaysCCPM(); }, 3000); -} - void PrivateChat::logMessage(const string& aMessage) { if (SETTING(LOG_PRIVATE_CHAT)) { ParamMap params; diff --git a/airdcpp/PrivateChat.h b/airdcpp/PrivateChat.h index f010f488..43787eee 100644 --- a/airdcpp/PrivateChat.h +++ b/airdcpp/PrivateChat.h @@ -124,11 +124,12 @@ namespace dcpp { handleMessage(message); } virtual void on(AdcCommand::PMI, UserConnection*, const AdcCommand& cmd) noexcept; + void onUserUpdated(const OnlineUser& aUser) noexcept; // ClientManagerListener - void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept; + void on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool wasOffline) noexcept; void on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept; - void on(ClientManagerListener::ClientDisconnected, const string& aHubUrl) noexcept; + void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept; bool online = true; diff --git a/airdcpp/StringDefs.h b/airdcpp/StringDefs.h index d0958ccc..eeaa629f 100644 --- a/airdcpp/StringDefs.h +++ b/airdcpp/StringDefs.h @@ -442,7 +442,7 @@ enum Strings { // @DontAdd FAVORITE_DIR_NAME, // "Favorite name" FAVORITE_HUBS, // "Favorite hubs" FAVORITE_HUB_ADDED, // "Favorite hub added" - FAVORITE_HUB_ALREADY_EXISTS, // "Hub already exists as a favorite" + FAVORITE_HUB_ALREADY_EXISTS, // "A favorite hub with the same address exists already" FAVORITE_HUB_DOES_NOT_EXIST, // "This hub is not a favorite hub" FAVORITE_HUB_IDENTITY, // "Identification (leave blank for defaults)" FAVORITE_HUB_PROPERTIES, // "Favorite hub properties"