@@ -207,6 +207,37 @@ void PrivateChat::checkCCPMTimeout() {
207
207
}
208
208
}
209
209
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
+
210
241
void PrivateChat::on (ClientManagerListener::UserDisconnected, const UserPtr& aUser, bool wentOffline) noexcept {
211
242
if (aUser != replyTo.user )
212
243
return ;
@@ -232,18 +263,6 @@ void PrivateChat::on(ClientManagerListener::UserDisconnected, const UserPtr& aUs
232
263
}
233
264
}
234
265
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
-
247
266
void PrivateChat::checkUserHub (bool wentOffline) {
248
267
auto hubs = ClientManager::getInstance ()->getHubs (replyTo.user ->getCID ());
249
268
if (hubs.empty ())
@@ -318,29 +337,6 @@ void PrivateChat::on(AdcCommand::PMI, UserConnection*, const AdcCommand& cmd) no
318
337
fire (PrivateChatListener::PMStatus (), this , type);
319
338
}
320
339
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
-
344
340
void PrivateChat::logMessage (const string& aMessage) {
345
341
if (SETTING (LOG_PRIVATE_CHAT)) {
346
342
ParamMap params;
0 commit comments