void MainWindow::msgUserState(const MumbleProto::UserState &msg) { ACTOR_INIT; SELF_INIT; ClientUser *pDst = ClientUser::get(msg.session()); bool bNewUser = false; if (! pDst) { if (msg.has_name()) { pDst = pmModel->addUser(msg.session(), u8(msg.name())); bNewUser = true; } else { return; } } if (msg.has_user_id()) pmModel->setUserId(pDst, msg.user_id()); if (msg.has_hash()) { pmModel->setHash(pDst, u8(msg.hash())); const QString &name = Database::getFriend(pDst->qsHash); if (! name.isEmpty()) pmModel->setFriendName(pDst, name); if (Database::isLocalMuted(pDst->qsHash)) pDst->setLocalMute(true); if (Database::isLocalIgnored(pDst->qsHash)) pDst->setLocalIgnore(true); } if (bNewUser) g.l->log(Log::UserJoin, tr("%1 connected.").arg(Log::formatClientUser(pDst, Log::Source))); if (msg.has_self_deaf() || msg.has_self_mute()) { if (msg.has_self_mute()) pDst->setSelfMute(msg.self_mute()); if (msg.has_self_deaf()) pDst->setSelfDeaf(msg.self_deaf()); if (pSelf && pDst != pSelf && (pDst->cChannel == pSelf->cChannel)) { QString name = pDst->qsName; if (pDst->bSelfMute && pDst->bSelfDeaf) g.l->log(Log::OtherSelfMute, tr("%1 is now muted and deafened.").arg(Log::formatClientUser(pDst, Log::Target))); else if (pDst->bSelfMute) g.l->log(Log::OtherSelfMute, tr("%1 is now muted.").arg(Log::formatClientUser(pDst, Log::Target))); else g.l->log(Log::OtherSelfMute, tr("%1 is now unmuted.").arg(Log::formatClientUser(pDst, Log::Target))); } } if (msg.has_recording()) { pDst->setRecording(msg.recording()); // Do nothing during initial sync if (pSelf) { if (pDst == pSelf) { if (pDst->bRecording) { g.l->log(Log::Recording, tr("Recording started")); } else { g.l->log(Log::Recording, tr("Recording stopped")); } } else if (pDst->cChannel->allLinks().contains(pSelf->cChannel)) { if (pDst->bRecording) { g.l->log(Log::Recording, tr("%1 started recording.").arg(Log::formatClientUser(pDst, Log::Source))); } else { g.l->log(Log::Recording, tr("%1 stopped recording.").arg(Log::formatClientUser(pDst, Log::Source))); } } } } if (msg.has_priority_speaker()) { if (pSelf && ((pDst->cChannel == pSelf->cChannel) || (pSrc == pSelf))) { if ((pSrc == pDst) && (pSrc == pSelf)) { if (pDst->bPrioritySpeaker) { g.l->log(Log::YouMuted, tr("You revoked your priority speaker status.")); } else { g.l->log(Log::YouMuted, tr("You assumed priority speaker status.")); } } else if ((pSrc != pSelf) && (pDst == pSelf) ) { if (pDst->bPrioritySpeaker) { g.l->log(Log::YouMutedOther, tr("%1 revoked your priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } else { g.l->log(Log::YouMutedOther, tr("%1 gave you priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } } else if ((pSrc == pSelf) && (pSrc != pDst)) { if (pDst->bPrioritySpeaker) { g.l->log(Log::YouMutedOther, tr("You revoked priority speaker status for %1.").arg(Log::formatClientUser(pDst, Log::Target))); } else { g.l->log(Log::YouMutedOther, tr("You gave priority speaker status to %1.").arg(Log::formatClientUser(pDst, Log::Target))); } } else if ((pSrc == pDst) && (pSrc != pSelf)) { if (pDst->bPrioritySpeaker) { g.l->log(Log::OtherMutedOther, tr("%1 revoked own priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } else { g.l->log(Log::OtherMutedOther, tr("%1 assumed priority speaker status.").arg(Log::formatClientUser(pSrc, Log::Source))); } } else if ((pSrc != pSelf) && (pDst != pSelf)) { if (pDst->bPrioritySpeaker) { g.l->log(Log::OtherMutedOther, tr("%1 revoked priority speaker status for %2.").arg(Log::formatClientUser(pSrc, Log::Source), Log::formatClientUser(pDst, Log::Target))); } else if (!pDst->bPrioritySpeaker) { g.l->log(Log::OtherMutedOther, tr("%1 gave priority speaker status to %2.").arg(Log::formatClientUser(pSrc, Log::Source), Log::formatClientUser(pDst, Log::Target))); } } } pDst->setPrioritySpeaker(msg.priority_speaker()); } if (msg.has_deaf() || msg.has_mute() || msg.has_suppress()) { if (msg.has_mute()) pDst->setMute(msg.mute()); if (msg.has_deaf()) pDst->setDeaf(msg.deaf()); if (msg.has_suppress()) pDst->setSuppress(msg.suppress()); if (pSelf && ((pDst->cChannel == pSelf->cChannel) || (pSrc == pSelf))) { if (pDst == pSelf) { if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) { g.l->log(Log::YouMuted, tr("You were muted and deafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) { g.l->log(Log::YouMuted, tr("You were unmuted and undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } else { if (msg.has_mute()) { if (pDst->bMute) g.l->log(Log::YouMuted, tr("You were muted by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); else g.l->log(Log::YouMuted, tr("You were unmuted by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } if (msg.has_deaf()) { if (!pDst->bDeaf) g.l->log(Log::YouMuted, tr("You were undeafened by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } } if (msg.has_suppress()) { if (pDst->bSuppress) g.l->log(Log::YouMuted, tr("You were suppressed.")); else { if (msg.has_channel_id()) g.l->log(Log::YouMuted, tr("You were unsuppressed.")); else g.l->log(Log::YouMuted, tr("You were unsuppressed by %1.").arg(Log::formatClientUser(pSrc, Log::Source))); } } updateTrayIcon(); } else if (pSrc == pSelf) { if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) { g.l->log(Log::YouMutedOther, tr("You muted and deafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); } else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) { g.l->log(Log::YouMutedOther, tr("You unmuted and undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); } else { if (msg.has_mute()) { if (pDst->bMute) g.l->log(Log::YouMutedOther, tr("You muted %1.").arg(Log::formatClientUser(pDst, Log::Target))); else g.l->log(Log::YouMutedOther, tr("You unmuted %1.").arg(Log::formatClientUser(pDst, Log::Target))); } if (msg.has_deaf()) { if (!pDst->bDeaf) g.l->log(Log::YouMutedOther, tr("You undeafened %1.").arg(Log::formatClientUser(pDst, Log::Target))); } } if (msg.has_suppress()) { if (! msg.has_channel_id()) { if (pDst->bSuppress) g.l->log(Log::YouMutedOther, tr("You suppressed %1.").arg(Log::formatClientUser(pDst, Log::Target))); else g.l->log(Log::YouMutedOther, tr("You unsuppressed %1.").arg(Log::formatClientUser(pDst, Log::Target))); } } } else { if (msg.has_mute() && msg.has_deaf() && pDst->bMute && pDst->bDeaf) { g.l->log(Log::OtherMutedOther, tr("%1 muted and deafened by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); } else if (msg.has_mute() && msg.has_deaf() && !pDst->bMute && !pDst->bDeaf) { g.l->log(Log::OtherMutedOther, tr("%1 unmuted and undeafened by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); } else { if (msg.has_mute()) { if (pDst->bMute) g.l->log(Log::OtherMutedOther, tr("%1 muted by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); else g.l->log(Log::OtherMutedOther, tr("%1 unmuted by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); } if (msg.has_deaf()) { if (!pDst->bDeaf) g.l->log(Log::OtherMutedOther, tr("%1 undeafened by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); } } if (msg.has_suppress()) { if (! msg.has_channel_id()) { if (pDst->bSuppress) g.l->log(Log::OtherMutedOther, tr("%1 suppressed by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); else g.l->log(Log::OtherMutedOther, tr("%1 unsuppressed by %2.").arg(Log::formatClientUser(pDst, Log::Target), Log::formatClientUser(pSrc, Log::Source))); } } } } } if (msg.has_channel_id()) { Channel *c = Channel::get(msg.channel_id()); if (!c) { qWarning("MessageUserMove for unknown channel."); c = Channel::get(0); } Channel *old = pDst->cChannel; if (c != old) { bool log = pSelf && !((pDst == pSelf) && (pSrc == pSelf)); if (log) { if (pDst == pSelf) { g.l->log(Log::ChannelJoin, tr("You were moved to %1 by %2.").arg(Log::formatChannel(c)).arg(Log::formatClientUser(pSrc, Log::Source))); } else if (pDst->cChannel == pSelf->cChannel) { if (pDst == pSrc) g.l->log(Log::ChannelLeave, tr("%1 moved to %2.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(c))); else g.l->log(Log::ChannelLeave, tr("%1 moved to %2 by %3.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(c)).arg(Log::formatClientUser(pSrc, Log::Source))); } else if (pSrc == pSelf) { g.l->log(Log::ChannelJoin, tr("You moved %1 to %2.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(c))); } } pmModel->moveUser(pDst, c); if (pDst == pSelf) { g.mw->updateChatBar(); qsDesiredChannel = c->getPath(); } if (log && (pDst != pSelf) && (pDst->cChannel == pSelf->cChannel)) { if (pDst == pSrc) g.l->log(Log::ChannelJoin, tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target))); else g.l->log(Log::ChannelJoin, tr("%1 moved in from %2 by %3.").arg(Log::formatClientUser(pDst, Log::Target)).arg(Log::formatChannel(old)).arg(Log::formatClientUser(pSrc, Log::Source))); if (pDst->bRecording) g.l->log(Log::Recording, tr("%1 is recording").arg(Log::formatClientUser(pDst, Log::Target))); } } } if (msg.has_name()) { QString oldName = pDst->qsName; QString newName = u8(msg.name()); pmModel->renameUser(pDst, newName); if (! oldName.isNull() && oldName != newName) { g.l->log(Log::UserRenamed, tr("%1 renamed to %2.").arg(Log::formatClientUser(pDst, Log::Target, oldName), Log::formatClientUser(pDst, Log::Target))); } } if (msg.has_texture_hash()) { pDst->qbaTextureHash = blob(msg.texture_hash()); pDst->qbaTexture = QByteArray(); g.o->verifyTexture(pDst); } if (msg.has_texture()) { pDst->qbaTexture = blob(msg.texture()); if (pDst->qbaTexture.isEmpty()) { pDst->qbaTextureHash = QByteArray(); } else { pDst->qbaTextureHash = sha1(pDst->qbaTexture); Database::setBlob(pDst->qbaTextureHash, pDst->qbaTexture); } g.o->verifyTexture(pDst); } if (msg.has_comment_hash()) pmModel->setCommentHash(pDst, blob(msg.comment_hash())); if (msg.has_comment()) pmModel->setComment(pDst, u8(msg.comment())); if (msg.icons_size()) { QList<QByteArray> ql; for (int i=0;i<msg.icons_size();++i) { ql << blob(msg.icons(i)); } pmModel->setIcons(pDst, ql); } }
void MumbleClient::processUserState(quint8 *message, quint64 size) { MumbleProto::UserState us; us.ParseFromArray(message,size); if((_session_id==-1) && (us.has_channel_id())) { _channel_id = us.channel_id(); qDebug() << " Joined channel: " << _channel_id; } if(us.session() == _session_id) { if(us.has_channel_id()) { _channel_id = us.channel_id(); qDebug() << " Joined channel: " << _channel_id; if(_channel_id > 1) { emit channelReady(_channel_id); } } for(int i=0; i < _stations.size(); i++) { Station *s = _stations.at(i); if(s->_id == _session_id) { delete s; s = NULL; _stations.remove(i); } } } else { bool set_station = false; for(int i=0; i < _stations.size(); i++) { Station *s = _stations.at(i); if(s->_id == us.session()) { s->_conference_id = us.channel_id(); if(us.has_self_mute()) s->_mute = us.self_mute(); if(us.has_deaf()) s->_deaf = us.self_deaf(); if(us.has_comment()) s->_callsign = QString::fromStdString(us.comment()); set_station = true; } } if(!set_station) { Station *s = new Station; s->_id = us.session(); s->_radio_id = QString::fromStdString(us.name()); s->_conference_id = us.channel_id(); if(us.has_self_mute()) s->_mute = us.self_mute(); if(us.has_deaf()) s->_deaf = us.self_deaf(); if(us.has_comment()) s->_callsign = QString::fromStdString(us.comment()); _stations.push_back(s); emit newStation(s); } } /* Just debug code for(int i = 0;i < _stations.size();i++) { Station *s = _stations.at(i); qDebug() << "Session: " << QString::number(s->_id) << " radio_id: " << s->_radio_id << " channel: " << QString::number(s->_conference_id) << s->_callsign; } */ StationList sl; for(int i =0; i<_stations.size(); ++i) { sl.append(*(_stations.at(i))); } emit onlineStations(sl); }