Skip to content

Commit 5771bda

Browse files
committed
Merge commit '0ae646141ad258e72d69c3955d77c6a850b20aef'
2 parents 3e65d6f + 0ae6461 commit 5771bda

File tree

5 files changed

+50
-45
lines changed

5 files changed

+50
-45
lines changed

airdcpp-core/airdcpp/DirectoryListing.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -1063,14 +1063,18 @@ void DirectoryListing::matchQueueImpl() noexcept {
10631063
}
10641064

10651065
void DirectoryListing::on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool /*wentOffline*/) noexcept {
1066-
if (aUser != hintedUser.user) {
1067-
return;
1068-
}
1069-
1070-
fire(DirectoryListingListener::UserUpdated());
1066+
onUserUpdated(aUser);
10711067
}
10721068
void DirectoryListing::on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept {
1073-
if (aUser.getUser() != hintedUser.user) {
1069+
onUserUpdated(aUser);
1070+
}
1071+
1072+
void DirectoryListing::on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool /*wasOffline*/) noexcept {
1073+
onUserUpdated(aUser);
1074+
}
1075+
1076+
void DirectoryListing::onUserUpdated(const UserPtr& aUser) noexcept {
1077+
if (aUser != hintedUser.user) {
10741078
return;
10751079
}
10761080

airdcpp-core/airdcpp/DirectoryListing.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,12 @@ class DirectoryListing : public intrusive_ptr_base<DirectoryListing>, public Use
274274

275275
// ClientManagerListener
276276
void on(ClientManagerListener::DirectSearchEnd, const string& aToken, int resultCount) noexcept;
277-
void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept;
277+
278+
void on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool wasOffline) noexcept;
278279
void on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept;
280+
void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept;
281+
282+
void onUserUpdated(const UserPtr& aUser) noexcept;
279283

280284
void on(TimerManagerListener::Second, uint64_t aTick) noexcept;
281285

airdcpp-core/airdcpp/PrivateChat.cpp

+31-35
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,37 @@ void PrivateChat::checkCCPMTimeout() {
207207
}
208208
}
209209

210+
void PrivateChat::onUserUpdated(const OnlineUser& aUser) noexcept {
211+
if (aUser.getUser() != replyTo.user)
212+
return;
213+
214+
setSupportsCCPM(ClientManager::getInstance()->getSupportsCCPM(replyTo, lastCCPMError));
215+
delayEvents.addEvent(USER_UPDATE, [this] {
216+
if (!online) {
217+
auto hubNames = ClientManager::getInstance()->getFormatedHubNames(replyTo);
218+
auto nicks = ClientManager::getInstance()->getFormatedNicks(replyTo);
219+
statusMessage(STRING(USER_WENT_ONLINE) + " [" + nicks + " - " + hubNames + "]",
220+
LogMessage::SEV_INFO);
221+
222+
// online from a different hub?
223+
checkUserHub(false);
224+
online = true;
225+
}
226+
227+
fire(PrivateChatListener::UserUpdated(), this);
228+
}, 1000);
229+
230+
delayEvents.addEvent(CCPM_AUTO, [this] { checkAlwaysCCPM(); }, 3000);
231+
}
232+
233+
void PrivateChat::on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool /*wasOffline*/) noexcept {
234+
onUserUpdated(aUser);
235+
}
236+
237+
void PrivateChat::on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept {
238+
onUserUpdated(aUser);
239+
}
240+
210241
void PrivateChat::on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept{
211242
if (aUser != replyTo.user)
212243
return;
@@ -232,18 +263,6 @@ void PrivateChat::on(ClientManagerListener::UserDisconnected, const UserPtr& aUs
232263
}
233264
}
234265

235-
/*
236-
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..
237-
This listener comes from the main thread so we should be able to pass the next speaker message before any other messages.
238-
*/
239-
void PrivateChat::on(ClientManagerListener::ClientDisconnected, const string& aHubUrl) noexcept {
240-
if (aHubUrl == getHubUrl()) {
241-
checkUserHub(true);
242-
fire(PrivateChatListener::UserUpdated(), this);
243-
}
244-
}
245-
246-
247266
void PrivateChat::checkUserHub(bool wentOffline) {
248267
auto hubs = ClientManager::getInstance()->getHubs(replyTo.user->getCID());
249268
if (hubs.empty())
@@ -318,29 +337,6 @@ void PrivateChat::on(AdcCommand::PMI, UserConnection*, const AdcCommand& cmd) no
318337
fire(PrivateChatListener::PMStatus(), this, type);
319338
}
320339

321-
void PrivateChat::on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept{
322-
if (aUser.getUser() != replyTo.user)
323-
return;
324-
325-
setSupportsCCPM(ClientManager::getInstance()->getSupportsCCPM(replyTo, lastCCPMError));
326-
delayEvents.addEvent(USER_UPDATE, [this] {
327-
if (!online) {
328-
auto hubNames = ClientManager::getInstance()->getFormatedHubNames(replyTo);
329-
auto nicks = ClientManager::getInstance()->getFormatedNicks(replyTo);
330-
statusMessage(STRING(USER_WENT_ONLINE) + " [" + nicks + " - " + hubNames + "]",
331-
LogMessage::SEV_INFO);
332-
333-
// online from a different hub?
334-
checkUserHub(false);
335-
online = true;
336-
}
337-
338-
fire(PrivateChatListener::UserUpdated(), this);
339-
}, 1000);
340-
341-
delayEvents.addEvent(CCPM_AUTO, [this] { checkAlwaysCCPM(); }, 3000);
342-
}
343-
344340
void PrivateChat::logMessage(const string& aMessage) {
345341
if (SETTING(LOG_PRIVATE_CHAT)) {
346342
ParamMap params;

airdcpp-core/airdcpp/PrivateChat.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ namespace dcpp {
124124
handleMessage(message);
125125
}
126126
virtual void on(AdcCommand::PMI, UserConnection*, const AdcCommand& cmd) noexcept;
127+
void onUserUpdated(const OnlineUser& aUser) noexcept;
127128

128129
// ClientManagerListener
129-
void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept;
130+
void on(ClientManagerListener::UserConnected, const OnlineUser& aUser, bool wasOffline) noexcept;
130131
void on(ClientManagerListener::UserUpdated, const OnlineUser& aUser) noexcept;
131-
void on(ClientManagerListener::ClientDisconnected, const string& aHubUrl) noexcept;
132+
void on(ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept;
132133

133134
bool online = true;
134135

airdcpp-core/airdcpp/StringDefs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ enum Strings { // @DontAdd
442442
FAVORITE_DIR_NAME, // "Favorite name"
443443
FAVORITE_HUBS, // "Favorite hubs"
444444
FAVORITE_HUB_ADDED, // "Favorite hub added"
445-
FAVORITE_HUB_ALREADY_EXISTS, // "Hub already exists as a favorite"
445+
FAVORITE_HUB_ALREADY_EXISTS, // "A favorite hub with the same address exists already"
446446
FAVORITE_HUB_DOES_NOT_EXIST, // "This hub is not a favorite hub"
447447
FAVORITE_HUB_IDENTITY, // "Identification (leave blank for defaults)"
448448
FAVORITE_HUB_PROPERTIES, // "Favorite hub properties"

0 commit comments

Comments
 (0)