Skip to content

Commit

Permalink
Squashed 'airdcpp-core/' changes from 4fddc37..c00ee91
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maksis committed Jan 20, 2016
1 parent 9fed2ea commit 0ae6461
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 45 deletions.
16 changes: 10 additions & 6 deletions airdcpp/DirectoryListing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion airdcpp/DirectoryListing.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,12 @@ class DirectoryListing : public intrusive_ptr_base<DirectoryListing>, 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;

Expand Down
66 changes: 31 additions & 35 deletions airdcpp/PrivateChat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions airdcpp/PrivateChat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion airdcpp/StringDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0ae6461

Please sign in to comment.